From da32df40a0cfb50a8569ee6e2902ad9b1f33d8a0 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Fri, 23 Feb 2024 09:43:13 +0100 Subject: [PATCH] WORKFLOW: fixing the source branch fetch [skip ci] --- .../cooker-selfhosted-persistent.yml | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/cooker-selfhosted-persistent.yml b/.github/workflows/cooker-selfhosted-persistent.yml index 14f28fbf..68e858e7 100644 --- a/.github/workflows/cooker-selfhosted-persistent.yml +++ b/.github/workflows/cooker-selfhosted-persistent.yml @@ -46,6 +46,33 @@ jobs: - name: Generate cooker build ID run: "/bin/bash ${GITHUB_WORKSPACE}/automation_tools/cooker_build_id.sh" + - name: Get branch name + id: branch_name + run: echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||')" >> $GITHUB_ENV + + # if it's a feature branch it will not marked as "latest" cooker version + - name: "Set makeLatest (cooker only)" + run: | + if [[ "$BRANCH_NAME" == 'feat/'* || "$BRANCH_NAME" == 'refs/'* ]]; then + echo "MAKE_LATEST=false" >> $GITHUB_ENV + else + echo "MAKE_LATEST=true" >> $GITHUB_ENV + fi + + # if the branch is coming from a PR the tag should be manually built + - name: "Generate version tag" + run: | + if [[ "$BRANCH_NAME" == 'refs/'* ]]; then + pr_number=$(echo ${{env.BRANCH_NAME}} | awk -F'/' '{print $3}') + source_branch=$(git show "refs/pull/$pr_number/merge" --no-patch --format="%P" | cut -d' ' -f2 | cut -d'/' -f3) + source_branch=${source_branch//\//-} + echo "[DEBUG] source branch is: $source_branch" + echo "TAG=PR-$pr_number-$source_branch-${{ env.buildid }}" >> $GITHUB_ENV + else + echo "TAG=${{env.BRANCH_NAME}}-${{ env.buildid }}" >> $GITHUB_ENV + fi + echo "Version TAG: ${{ env.TAG }}" + # backing up manifest in case download fails and hashes must be recalculated - name: Manifest backup run: "cp ${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml ${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml.bak" @@ -106,30 +133,6 @@ jobs: id: commits continue-on-error: true - - name: Get branch name - id: branch_name - run: echo "BRANCH_NAME=$(echo $GITHUB_REF | sed 's|refs/heads/||')" >> $GITHUB_ENV - - # if it's a feature branch it will not marked as "latest" cooker version - - name: "Set makeLatest (cooker only)" - run: | - if [[ "$BRANCH_NAME" == 'feat/'* || "$BRANCH_NAME" == 'ref/'* ]]; then - echo "MAKE_LATEST=false" >> $GITHUB_ENV - else - echo "MAKE_LATEST=true" >> $GITHUB_ENV - fi - - # if the branch is coming from a PR the tag should be manually built - - name: "Generate version tag" - run: | - if [[ "$BRANCH_NAME" == 'refs/'* ]]; then - pr_number=$(echo ${{env.BRANCH_NAME}} | awk -F'/' '{print $3}') - original_branch=$(git ls-remote --heads origin "refs/pull/$pr_number/head" | cut -d'/' -f3) - echo "TAG=PR-$pr_number-$original_branch-${{ env.buildid }}" >> $GITHUB_ENV - else - echo "TAG=${{env.BRANCH_NAME}}-${{ env.buildid }}" >> $GITHUB_ENV - fi - - name: Publish the flatpak in a new cooker release uses: ncipollo/release-action@v1 with: