Skip to content

Commit

Permalink
ci/cd: add Workflow invalidation, refactor Continuous integration, re…
Browse files Browse the repository at this point in the history
…name Continuous delivery
  • Loading branch information
kamilsk committed Apr 1, 2023
1 parent f634182 commit 86733c1
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

schedule:
- cron: 0 7 1 * *
- cron: 0 7 * * 0

jobs:
delete:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd.docker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: continuous delivery (docker)
name: Continuous delivery (Docker)

on:
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd.vercel.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: continuous delivery (vercel)
name: Continuous delivery (Vercel)

on:
workflow_dispatch:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ jobs:
with: { fetch-depth: 0 }

- name: Set up Node.js environment
id: app
uses: actions/setup-node@v3
with: { node-version: 16, cache: npm }
- name: Install application dependencies if needed
run: npm ci --ignore-scripts --include=dev
env: { FONTAWESOME_TOKEN: '${{ secrets.FONTAWESOME_TOKEN }}' }
if: steps.app.outputs.cache-hit != 'true'

- name: Set up Node.js environment
id: tools
uses: actions/setup-node@v3
with: { node-version: 16, cache: npm, cache-dependency-path: tools/package-lock.json }
- name: Install tooling dependencies if needed
run: ./Taskfile tools npm ci
if: steps.tools.outputs.cache-hit != 'true'

# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
# - name: Cache tooling dependencies
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Workflow invalidation

on:
workflow_dispatch:
inputs:
pattern:
description: The name of workflow to clean.
type: choice
options:
- Cache invalidation
- Continuous integration
- Continuous delivery (Vercel)
- Continuous delivery (Docker)
# - Dependabot at weekends
# - Documentation delivery
# - Tools validation
- Workflow invalidation
default: Workflow invalidation
required: true
dry_run:
description: Only log actions, do not perform any delete operations.
type: boolean
required: false

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 }}
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: Send Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ contains(needs.*.result, 'failure') && 'failure' || 'success' }}
SLACK_ICON: https://github.com/github.png?size=64
SLACK_TITLE: '🗑️ ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

0 comments on commit 86733c1

Please sign in to comment.