From 40ed12913248dbab1c92bdb59a16704ff26c8a6d Mon Sep 17 00:00:00 2001 From: XargonWan Date: Sat, 24 Aug 2024 22:07:12 +0900 Subject: [PATCH] WORKFLOW: tentative PR branch name fixes -fix2 [skip ci] --- .github/workflows/cooker-selfhosted.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cooker-selfhosted.yml b/.github/workflows/cooker-selfhosted.yml index e24636bd..60264ac1 100644 --- a/.github/workflows/cooker-selfhosted.yml +++ b/.github/workflows/cooker-selfhosted.yml @@ -81,14 +81,19 @@ jobs: # Check if the event is related to a pull request if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "pull_request_target" ]]; then - pr_number=$(echo "$GITHUB_REF" | awk -F'/' '{print $3}') - source_branch=$(curl -s "https://api.github.com/repos/RetroDECK/RetroDECK/pulls/$pr_number" | jq -r '.head.ref') - source_branch=${source_branch//\//-} # Replace '/' with '-' in the branch name + # Use GITHUB_HEAD_REF to get the source branch + source_branch="${GITHUB_HEAD_REF}" + + # Replace '/' with '-' in the branch name + source_branch=${source_branch//\//-} echo "[DEBUG] source branch is: $source_branch" - echo "TAG=PR-$pr_number-$(echo $source_branch-${{ env.buildid }} | sed 's/\//-/g')" >> $GITHUB_ENV - echo "MAKE_LATEST=false" >> $GITHUB_ENV # if it's a feature branch it will not marked as "latest" cooker version + + # Generate the tag for a pull request + echo "TAG=PR-$GITHUB_RUN_ID-$source_branch-${{ env.buildid }}" >> $GITHUB_ENV + echo "MAKE_LATEST=false" >> $GITHUB_ENV # Not marked as the latest cooker version if it's a feature branch else - TAG="$MANIFEST_VERSION-${{ env.buildid }} | sed 's/\//-/g'" + # Generate the tag for non-pull request branches + TAG="$MANIFEST_VERSION-${{ env.buildid }}" echo "TAG=$TAG" >> $GITHUB_ENV echo "MAKE_LATEST=true" >> $GITHUB_ENV fi