-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #620: fix cache keys, sync Cache invalidation workflow
- Loading branch information
Showing
2 changed files
with
26 additions
and
17 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 |
---|---|---|
@@ -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 }} |
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