From a2fcf8377c21494095df401a6fba0e6d09b15b43 Mon Sep 17 00:00:00 2001 From: Rock Neurotiko Date: Mon, 24 Feb 2025 11:47:05 +0100 Subject: [PATCH 1/2] Use branch name on PR too --- .github/actions/get-env/action.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-env/action.yaml b/.github/actions/get-env/action.yaml index 5b699607..38871ace 100644 --- a/.github/actions/get-env/action.yaml +++ b/.github/actions/get-env/action.yaml @@ -16,6 +16,9 @@ outputs: description: 'Name of the environment' value: ${{ steps.get-env.outputs.env }} +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + runs: using: 'composite' steps: @@ -23,9 +26,9 @@ runs: name: "Get environment from branch name" id: get-env run: | - if [[ "${{ github.ref_name }}" != "${{ inputs.main_branch }}" ]] + if [[ "${{ env.BRANCH_NAME }}" != "${{ inputs.main_branch }}" ]] then - filter=$( cut -d '-' -f 1 <<< ${{ github.ref_name }} ) + filter=$( cut -d '-' -f 1 <<< ${{ env.BRANCH_NAME }} ) read -ra valid_envs <<< "${{ inputs.valid_envs }}" for tmp in "${valid_envs[@]}" do @@ -38,6 +41,6 @@ runs: echo "Invalid environment: ${filter}" exit 1 else - echo "ERROR: Wrong branch name: ${{ github.ref_name }}" + echo "ERROR: Wrong branch name: ${{ env.BRANCH_NAME }}" exit 1 fi From 1e3b8856b1722ff0c84f7e3282846bdf17f918aa Mon Sep 17 00:00:00 2001 From: Rock Neurotiko Date: Mon, 24 Feb 2025 13:20:06 +0100 Subject: [PATCH 2/2] Move env --- .github/actions/get-env/action.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-env/action.yaml b/.github/actions/get-env/action.yaml index 38871ace..58406aa4 100644 --- a/.github/actions/get-env/action.yaml +++ b/.github/actions/get-env/action.yaml @@ -16,15 +16,14 @@ outputs: description: 'Name of the environment' value: ${{ steps.get-env.outputs.env }} -env: - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - runs: using: 'composite' steps: - shell: bash name: "Get environment from branch name" id: get-env + env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} run: | if [[ "${{ env.BRANCH_NAME }}" != "${{ inputs.main_branch }}" ]] then