-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci/cd: add dependabot and Workflow runs cleanup
- Loading branch information
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Define notification message | ||
description: Identify an appropriate notification message. | ||
branding: | ||
icon: 'message-square' | ||
color: 'green' | ||
|
||
inputs: | ||
emoji: | ||
description: Prefix for the title. | ||
default: 🤖 | ||
|
||
channel: | ||
description: Notification channel. | ||
required: true | ||
|
||
success: | ||
description: Is the result successful? | ||
required: true | ||
default: 'true' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Define notification message | ||
id: message | ||
run: | | ||
if [ '${{ github.event.head_commit.message != null }}' == 'true' ] | ||
then | ||
(cat <<-message | ||
txt=${{ github.event.head_commit.message }} | ||
message | ||
) | head -1 >> $GITHUB_OUTPUT | ||
elif [ '${{ github.event.inputs.reason != null }}' == 'true' ] | ||
then | ||
(cat <<-message | ||
txt=${{ github.event.inputs.reason }} | ||
message | ||
) | head -1 >> $GITHUB_OUTPUT | ||
elif [ '${{ github.event.schedule != null }}' == 'true' ] | ||
then | ||
echo txt='regular healthcheck' >> $GITHUB_OUTPUT | ||
else | ||
echo Cannot define notification message && exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Send Slack notification | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_COLOR: ${{ inputs.success == 'true' && 'success' || 'failure' }} | ||
SLACK_FOOTER: made with ❤️ for everyone by <https://www.octolab.org/|OctoLab> | ||
SLACK_ICON: https://cdn.octolab.org/geek/octolab.png | ||
SLACK_MESSAGE: ${{ steps.message.outputs.txt }} | ||
SLACK_TITLE: '${{ inputs.emoji }} ${{ github.repository }}: ${{ github.workflow }}' | ||
SLACK_USERNAME: Notifier | ||
SLACK_WEBHOOK: ${{ inputs.channel }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
time: '05:00' | ||
timezone: UTC | ||
labels: | ||
- 'type: improvement' | ||
- 'scope: inventory' | ||
- 'scope: deps' | ||
commit-message: | ||
prefix: 'ci/cd' | ||
include: 'scope' | ||
open-pull-requests-limit: 30 | ||
|
||
- package-ecosystem: docker | ||
directory: / | ||
schedule: | ||
interval: daily | ||
time: '05:00' | ||
timezone: UTC | ||
labels: | ||
- 'type: improvement' | ||
- 'scope: inventory' | ||
- 'scope: deps' | ||
commit-message: | ||
prefix: 'ci/cd' | ||
include: 'scope' | ||
open-pull-requests-limit: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Workflow runs cleanup | ||
|
||
on: | ||
schedule: | ||
- cron: 0 6 1 * * # at 06:00 on day-of-month 1, UTC | ||
|
||
workflow_dispatch: | ||
inputs: | ||
pattern: | ||
description: The name of workflow to clean. | ||
type: choice | ||
options: | ||
- All | ||
- Continuous delivery | ||
- Workflow runs cleanup | ||
default: Workflow runs cleanup | ||
required: true | ||
dry_run: | ||
description: Only log actions, do not perform any delete operations. | ||
type: boolean | ||
required: false | ||
reason: | ||
description: The reason for dispatching it manually. | ||
type: string | ||
default: manual healthcheck | ||
required: true | ||
|
||
jobs: | ||
delete: | ||
name: Deleting | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Delete workflow runs | ||
uses: Mattraks/delete-workflow-runs@v2 | ||
with: | ||
token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
delete_workflow_pattern: ${{ github.event.inputs.pattern || 'all' }} | ||
dry_run: ${{ fromJSON('["", "true"]')[github.event.inputs.dry_run == 'true'] }} | ||
retain_days: 0 | ||
keep_minimum_runs: 0 | ||
|
||
notify: | ||
name: Notifying | ||
needs: [ delete ] | ||
runs-on: ubuntu-latest | ||
if: failure() || success() | ||
|
||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: { fetch-depth: 0 } | ||
|
||
- name: Send notification | ||
uses: ./.github/actions/notify | ||
continue-on-error: true | ||
with: | ||
emoji: 🧹 | ||
channel: ${{ secrets.SLACK_WEBHOOK }} | ||
success: ${{ ! contains(needs.*.result, 'failure') }} |