Skip to content

refactor: improve code readability and error handling #85

refactor: improve code readability and error handling

refactor: improve code readability and error handling #85

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: 🌳 Pull Request
on:
pull_request_target:
pull_request:
types:
- closed
jobs:
# To use this job, you will need to set up a .github/labeler.yml
# file with configuration. For more information, see:
# https://github.com/actions/labeler
label:
name: 🏷️ Label
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_target'
permissions:
contents: read
pull-requests: write
steps:
# https://github.com/actions/labeler/tree/8558fd74291d67161a8a78ce36a881fa63b766a9
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9
with:
sync-labels: true
cleanup-cache:
name: 🧹 Cleanup cache
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed'
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
steps:
# https://github.com/actions/checkout/tree/11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
- name: 🗑️ Delete cache
run: |
echo "Fetching list of cache key"
cacheKeysForPR=$(gh cache list --ref $BRANCH --limit 100 --json id --jq '.[].id')
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh cache delete $cacheKey
done
echo "Done"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge