From 86733c1b00d1a38099b7e6f120747cb1c42de703 Mon Sep 17 00:00:00 2001 From: Kamil Samigullin Date: Sat, 1 Apr 2023 08:30:03 +0300 Subject: [PATCH] ci/cd: add Workflow invalidation, refactor Continuous integration, rename Continuous delivery --- .github/workflows/caches.yml | 2 +- .github/workflows/cd.docker.yml | 2 +- .github/workflows/cd.vercel.yml | 2 +- .github/workflows/ci.yml | 5 +++ .github/workflows/runs.yml | 55 +++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/runs.yml diff --git a/.github/workflows/caches.yml b/.github/workflows/caches.yml index f0cab304..64642fdd 100644 --- a/.github/workflows/caches.yml +++ b/.github/workflows/caches.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: schedule: - - cron: 0 7 1 * * + - cron: 0 7 * * 0 jobs: delete: diff --git a/.github/workflows/cd.docker.yml b/.github/workflows/cd.docker.yml index f6326e3e..72ee90bf 100644 --- a/.github/workflows/cd.docker.yml +++ b/.github/workflows/cd.docker.yml @@ -1,4 +1,4 @@ -name: continuous delivery (docker) +name: Continuous delivery (Docker) on: workflow_dispatch: diff --git a/.github/workflows/cd.vercel.yml b/.github/workflows/cd.vercel.yml index 612b9a3f..3bfeeea6 100644 --- a/.github/workflows/cd.vercel.yml +++ b/.github/workflows/cd.vercel.yml @@ -1,4 +1,4 @@ -name: continuous delivery (vercel) +name: Continuous delivery (Vercel) on: workflow_dispatch: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 411dcd2a..0eebdd0e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/runs.yml b/.github/workflows/runs.yml new file mode 100644 index 00000000..ac7cd5a9 --- /dev/null +++ b/.github/workflows/runs.yml @@ -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 }}