[ODS-6318] Issue with routing around the identities hooks - v7 #291
Workflow file for this run
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
# SPDX-License-Identifier: Apache-2.0 | |
# Licensed to the Ed-Fi Alliance under one or more agreements. | |
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | |
# See the LICENSE and NOTICES files in the project root for more information. | |
name: Cleanup Caches by a branch | |
on: | |
pull_request: | |
branches: [main, 'b-v*-patch*','feature-*'] | |
types: [ closed ] | |
env: | |
GH_TOKEN: ${{ secrets.REPO_DISPATCH_TOKEN }} | |
REPOSITORY_OWNER: ${{ GITHUB.REPOSITORY_OWNER }} | |
jobs: | |
cleanup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for Repo Dispatch Token | |
if: ${{ env.REPOSITORY_OWNER == 'Ed-Fi-Alliance-OSS' && env.GH_TOKEN == '' }} | |
run: | | |
echo "::error::Missing GitHub Token" | |
exit 1 | |
- name: Check out code | |
if: ${{ env.GH_TOKEN != '' }} | |
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4 | |
- name: Cleanup | |
run: | | |
gh extension install actions/gh-actions-cache | |
REPO=${{ github.repository }} | |
PULLREQUESTBRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" | |
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $PULLREQUESTBRANCH | cut -f 1 ) | |
## Setting this to not fail the workflow while deleting cache keys. | |
set +e | |
echo "Deleting caches for PULLREQUESTBRANCH $PULLREQUESTBRANCH..." | |
for cacheKey in $cacheKeysForPR | |
do | |
gh actions-cache delete $cacheKey -R $REPO -B $PULLREQUESTBRANCH --confirm | |
done | |
WORKINGBRANCH=${{ GITHUB.HEAD_REF }} | |
echo "HEAD_REF: " ${{ GITHUB.HEAD_REF }} | |
echo "REF_NAME: " ${{ GITHUB.REF_NAME }} | |
echo "Fetching list of cache key" | |
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $WORKINGBRANCH | cut -f 1 ) | |
set +e | |
echo "Deleting caches for WORKINGBRANCH $WORKINGBRANCH..." | |
for cacheKey in $cacheKeysForPR | |
do | |
gh actions-cache delete $cacheKey -R $REPO -B $WORKINGBRANCH --confirm | |
done | |
echo "Done" |