Skip to content

Update the image to support 4o #330

Update the image to support 4o

Update the image to support 4o #330

Workflow file for this run

# Ref: https://github.com/bitnami/charts/blob/main/.github/workflows/assign-asset-label.yml
name: '[Support] Assign asset label'
on:
pull_request_target:
types:
- opened
- reopened
- ready_for_review
permissions:
pull-requests: write
issues: write
contents: read
jobs:
assign-label:
name: Assign label
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 0
persist-credentials: true
- id: get-asset
name: Get modified assets
run: |
[[ "${{ secrets.SCRIPT_DEBUG }}" == "1" ]] && set -x || true
set -euo pipefail
# 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')"
# Adding || true to avoid "Process exited with code 1" errors
assets=($(echo "${files_changed}" | xargs dirname | tr ' ' '\n' | grep -e '^charts\/shared\/.*' | sed -nr "s|charts/shared/([^/]*).*|\1|p" | uniq | sort || true))
assets+=($(echo "${files_changed}" | xargs dirname | tr ' ' '\n' | grep -e '^charts\/iac\/.*' | sed -nr "s|charts/iac/([^/]*).*|\1|p" | uniq | sort || true))
assets+=($(echo "${files_changed}" | xargs dirname | tr ' ' '\n' | grep -e '^charts\/modules\/apps\/.*' | sed -nr "s|charts/modules/apps/([^/]*).*|\1|p" | uniq | sort || true))
assets+=($(echo "${files_changed}" | xargs dirname | tr ' ' '\n' | grep -e '^charts\/modules\/infra\/.*' | sed -nr "s|charts/modules/infra/([^/]*).*|\1|p" | uniq | sort || true))
assets+=($(echo "${files_changed}" | xargs dirname | tr ' ' '\n' | grep -e '^charts\/modules\/iac\/.*' | sed -nr "s|charts/modules/iac/([^/]*).*|\1|p" | uniq | sort || true))
if [[ "${#assets[@]}" -ne "0" ]]; then
echo "result=ok" >> $GITHUB_OUTPUT
echo "message=Adding label '${assets[@]}'" >> $GITHUB_OUTPUT
echo "name=$(echo ${assets[@]}|tr ' ' ', ')" >> $GITHUB_OUTPUT
else
echo "result=skip" >> $GITHUB_OUTPUT
echo "message=No label matches" >> $GITHUB_OUTPUT
echo "name=NONE" >> $GITHUB_OUTPUT
fi
- name: Show messages
uses: actions/github-script@v6
with:
script: |
if ("${{ steps.get-asset.outputs.result }}" != "ok" ) {
core.warning("${{ steps.get-asset.outputs.message }}")
} else {
core.info("${{ steps.get-asset.outputs.message }}")
}
- name: Labeling
if: ${{ steps.get-asset.outputs.result == 'ok' }}
uses: fmulero/labeler@1.0.5
with:
add-labels: "${{ steps.get-asset.outputs.name }}"