Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly set branch name in Cleanup workflow step name #119

Merged
merged 3 commits into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ on:
types:
- closed

permissions:
actions: write

env:
BRANCH: ${{ github.event_type == 'pull_request' && 'refs/pull/${{ github.event.pull_request.number }}/merge' || github.event.ref }}

jobs:
cleanup:
name: Cleanup at event ${{ github.event_name }} for branch ${{ env.BRANCH }}
name: Cleanup at event ${{ github.event_name }} for branch ${{ github.event_type == 'pull_request' && 'refs/pull/${{ github.event.pull_request.number }}/merge' || github.event.ref }}
if: github.event.ref_type == 'branch' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
runs-on: ubuntu-24.04
steps:
Expand All @@ -23,11 +26,23 @@ jobs:
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
deletedAny=0
for cacheKey in $cacheKeysForPR
do
deletedAny=1
gh cache delete $cacheKey
exitCode="$?"
if [ "$exitCode" -eq 0 ]; then
echo "deleted cache entry $cacheKey"
else
echo "failed to delete cache entry $cacheKey - exited with code $exitCode"
fi
done
echo "Done"
if [ "$deletedAny" -eq 0 ]; then
echo "No cache entries found"
else
echo "Done"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
Loading