diff --git a/.github/workflows/cleanup-cache-postpr.yml b/.github/workflows/cleanup-cache-postpr.yml index 9a2ffb0f61a..e24369a7b39 100644 --- a/.github/workflows/cleanup-cache-postpr.yml +++ b/.github/workflows/cleanup-cache-postpr.yml @@ -23,8 +23,8 @@ jobs: REPO=${{ github.repository }} - gh run download ${{ github.event.workflow_run.id }} -n pr_number - pr_number=`cat pr_number.txt` + pr_number=$(jq --raw-output .workflow_run.pull_requests[0].number < ${GITHUB_EVENT_PATH}) + echo "Clean up cache for PR ${pr_number}." BRANCH=refs/pull/${pr_number}/merge # Setting this to not fail the workflow while deleting cache keys. diff --git a/.github/workflows/post-pr.yml b/.github/workflows/post-pr.yml index 2768ef376cc..6fa886e4abb 100644 --- a/.github/workflows/post-pr.yml +++ b/.github/workflows/post-pr.yml @@ -4,17 +4,13 @@ on: types: - closed +# Because this workflow is run in the context of a pull_request event, it +# does not have the permission to remove caches. We use this workflow to +# trigger CleanUpCachePostPR to remove caches. + jobs: cleanup: runs-on: ubuntu-latest steps: - - name: Save PR number - env: - PR_NUMBER: ${{ github.event.number }} - run: | - echo $PR_NUMBER > pr_number.txt - - uses: actions/upload-artifact@v4 - with: - name: pr_number - path: pr_number.txt - retention-days: 1 + - name: Do nothing + run: echo "This workflow will trigger CleanUpCachePostPR."