get branch name #6
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
name: Main push | ||
on: | ||
push: | ||
branches: | ||
- main | ||
concurrency: | ||
group: ${{ github.workflow }}/${{ github.head_ref || github.ref_name || github.ref }} | ||
cancel-in-progress: true | ||
jobs: | ||
cache-cleanup: | ||
if: ${{ always() }} | ||
needs: test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# `actions:write` permission is required to delete caches | ||
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id | ||
actions: write | ||
contents: read | ||
defaults: | ||
# run: | ||
# working-directory: backend | ||
env: | ||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
- name: Cleanup | ||
run: | | ||
gh extension install actions/gh-actions-cache | ||
REPO=${{ github.repository }} | ||
## Setting this to not fail the workflow while deleting cache keys. | ||
set +e | ||
echo "Deleting bundle caches..." | ||
gh actions-cache delete ${{ runner.os }}-gems-v3-${{ hashFiles('./backend/Gemfile.lock') }} -R $REPO -B $BRANCH_NAME --confirm | ||
echo "Deleting asset caches..." | ||
gh actions-cache delete ${{ runner.os }}-assets-cache-${{ hashFiles('./backend/app/assets/**', './backend/vendor/assets/**', '!.git') }} -R $REPO -B $BRANCH_NAME --confirm | ||
echo "Done" | ||
env: | ||
GH_TOKEN: ${{ secrets.TOKEN }} |