Skip to content

Commit

Permalink
fix #620: fix cache keys, sync Cache invalidation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Mar 27, 2023
1 parent 30f46cc commit e8459ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
37 changes: 23 additions & 14 deletions .github/workflows/caches.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
name: cache invalidation
name: Cache invalidation

on:
workflow_dispatch:

schedule:
- cron: '0 7 1 * *' # https://crontab.guru/#0_7_1_%2A_%2A, CET==UTC+1
- cron: 0 7 1 * *

jobs:
drop:
delete:
name: Deleting
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout the repository
uses: actions/checkout@v3
with: { fetch-depth: 0 }

- run: |
gh extension install actions/gh-actions-cache
keys=$(gh actions-cache list -R ${{ github.repository }} | cut -f1)
- name: Install a GitHub CLI cache extension
run: gh extension install actions/gh-actions-cache
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup caches
run: |
keys=$(gh actions-cache list -R '${{ github.repository }}' | cut -f1)
if [ -z "${keys}" ]; then echo 'Nothing to do' && exit 0; fi
set +e
echo "Deleting caches..."
echo Deleting caches...
for key in ${keys}; do
gh actions-cache delete ${key} -R ${{ github.repository }} --confirm
gh actions-cache delete "${key}" -R '${{ github.repository }}' --confirm || true
done
echo "Done"
echo Done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

notify:
needs: [ drop ]
name: Notifying
needs: [ delete ]
runs-on: ubuntu-latest
if: failure() || success()

steps:
- uses: rtCamp/action-slack-notify@v2
- 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_TITLE: '🧹 ${{ github.repository }}: ${{ github.workflow }}'
SLACK_USERNAME: GitHub Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- uses: actions/cache@v3
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
id: cache
key: core-${{ hashFiles('package-lock.json') }}
id: core
- run: npm ci --ignore-scripts --include=dev
if: steps.cache.outputs.cache-hit != 'true'
if: steps.core.outputs.cache-hit != 'true'
env: { FONTAWESOME_TOKEN: '${{ secrets.FONTAWESOME_TOKEN }}' }
- run: npm run build

Expand Down

0 comments on commit e8459ef

Please sign in to comment.