From 6127cda5b946f945ee2da4edf5e2e26cdb5c680e Mon Sep 17 00:00:00 2001 From: Francois G Date: Fri, 21 Oct 2022 13:42:24 +0200 Subject: [PATCH] TECH-1001: Using a variable instead of a set name to trigger remote workflow (#1391) --- .github/workflows/on-code-change.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/on-code-change.yml b/.github/workflows/on-code-change.yml index 3a1b66b03dc..c97874c6b0d 100644 --- a/.github/workflows/on-code-change.yml +++ b/.github/workflows/on-code-change.yml @@ -291,12 +291,28 @@ jobs: runs-on: ubuntu-latest needs: [integration-tests, sonar-analysis, security-scan, vulnerability-scan, build] steps: + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v5.4 + - name: Preparing variables for remote branch + id: exports + shell: bash + run: | + # If we are in a PR, we use master for the remote branch + # If we are not in a PR, we use the current branch for the remote branch + if [[ "${{ github.event.pull_request.head.ref }}" == "" ]]; then + echo "Currently NOT in a PR: ${{ github.event.pull_request.head.ref }}, using ${{ steps.branch-name.outputs.current_branch }} as remote branch" + echo "remote_branch=${{ steps.branch-name.outputs.current_branch }}" >> $GITHUB_OUTPUT + else + echo "Currently in a PR with head: ${{ github.event.pull_request.head.ref }}, using master as remote branch" + echo "remote_branch=master" >> $GITHUB_OUTPUT + fi - name: Call Jahia-pack-private id: trigger-step uses: jonas-schievink/workflow-proxy@v1 with: workflow: do-it-all.yml - ref: master + ref: ${{ steps.exports.outputs.remote_branch }} repo: Jahia/jahia-pack-private wait-for-completion-timeout: 2h inputs: '{ "parent_image_tag": "${{needs.build.outputs.image_tag}}" }'