From 378c84c3d1fe4be6cec15ac6bffd6eec9efed1b4 Mon Sep 17 00:00:00 2001 From: Andy Wu Date: Thu, 18 Jan 2024 12:12:34 -0800 Subject: [PATCH] [fix] pr branch name --- .github/workflows/ci-publish.yaml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-publish.yaml b/.github/workflows/ci-publish.yaml index 6ad63276..5b6b36b7 100644 --- a/.github/workflows/ci-publish.yaml +++ b/.github/workflows/ci-publish.yaml @@ -15,24 +15,30 @@ jobs: # Add timestamp timestamp: runs-on: ubuntu-latest - # Trigger the workflow only if the PR is from dev branch - # if: ${{ github.event.pull_request.head.repo.full_name == 'dev2' }} + outputs: + PR_BRANCH_NAME: ${{ steps.get_pr_branch_name.outputs.PR_BRANCH_NAME }} steps: - name: Generate timestamp run: | echo "TIMESTAMP=$(TZ='America/Los_Angeles' date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV - echo ${{ github.event.pull_request.head.repo.full_name }} + echo ${{ github.head_ref }} - name: Print timestamp run: | echo "Execution time (Pacific Time Zone): $TIMESTAMP" + - name: Get PR branch name + id: get_pr_branch_name + run: | + echo "PR_BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_OUTPUT + echo "PR_BRANCH_NAME=$PR_BRANCH_NAME" + # Parse version from main branch parse-package-version-main: runs-on: ubuntu-latest needs: timestamp # Trigger the workflow only if the PR is from dev branch - if: ${{ github.event.pull_request.head.repo.full_name == 'dev2' }} + # if: ${{ needs.timestamp.outputs.PR_BRANCH_NAME == 'dev2' }} outputs: MAIN_VERSION: ${{ steps.parse_package_json.outputs.MAIN_VERSION }} steps: @@ -54,7 +60,7 @@ jobs: runs-on: ubuntu-latest needs: timestamp # Trigger the workflow only if the PR is from dev branch - if: ${{ github.event.pull_request.head.repo.full_name == 'dev2' }} + if: ${{ needs.timestamp.outputs.PR_BRANCH_NAME == 'dev2' }} outputs: DEV_VERSION: ${{ steps.parse_package_json.outputs.DEV_VERSION }} steps: @@ -73,9 +79,9 @@ jobs: build-test-publish: runs-on: ubuntu-latest - needs: [parse-package-version-main, parse-package-version-dev] + needs: [timestamp, parse-package-version-main, parse-package-version-dev] # Trigger the workflow only if the PR is from dev branch, and DEV_VERSION is different from MAIN_VERSION - if: github.event.pull_request.head.repo.full_name == 'dev2' && needs.parse-package-version-main.outputs.MAIN_VERSION != needs.parse-package-version-dev.outputs.DEV_VERSION + if: ${{ needs.timestamp.outputs.PR_BRANCH_NAME == 'dev2' }} && needs.parse-package-version-main.outputs.MAIN_VERSION != needs.parse-package-version-dev.outputs.DEV_VERSION steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1