[bitnami/containers] Reduce GitHub API requests (#27835)

* [bitnami/containers] Reduce GitHub API requests

Signed-off-by: Fran Mulero <fmulero@vmware.com>

* Use pr number as part of the temporary file

Signed-off-by: Fran Mulero <fmulero@vmware.com>

* Remove automated PRs from the 'Move closed issues' workflow

Signed-off-by: Fran Mulero <fmulero@vmware.com>

---------

Signed-off-by: Fran Mulero <fmulero@vmware.com>
This commit is contained in:
Fran Mulero
2023-03-23 10:45:53 +01:00
committed by GitHub
parent f15d114158
commit 1e05f989fa
4 changed files with 38 additions and 21 deletions

View File

@@ -13,12 +13,13 @@ jobs:
steps:
- id: get-asset
name: Get modified assets
env:
DIFF_URL: "${{github.event.pull_request.diff_url}}"
TEMP_FILE: "${{runner.temp}}/pr-${{github.event.number}}.diff"
run: |
# Using the Github API to detect the files changed as git merge-base stops working when the branch is behind
# and jitterbit/get-changed-files does not support pull_request_target
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
files_changed_data=$(curl -s --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -X GET -G "$URL")
files_changed="$(echo $files_changed_data | jq -r '.[] | .filename')"
# This request doesn't consume API calls.
curl -Lkso $TEMP_FILE $DIFF_URL
files_changed="$(sed -nr 's/[\-\+]{3} [ab]\/(.*)/\1/p' $TEMP_FILE | sort | uniq)"
# Adding || true to avoid "Process exited with code 1" errors
assets=($(echo "$files_changed" | xargs dirname | sed -nr "s|bitnami/([^/]*).*|\1|p" | sort | uniq || true))