Skip to content

Commit 17d2703

Browse files
fix branch extraction logic
1 parent 7bc87fb commit 17d2703

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

.github/workflows/ci-e2e.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,27 @@ jobs:
4141
steps:
4242
- name: Extract env vars for main
4343
shell: bash
44-
if: ${{ github.ref == 'refs/heads/main' }}
44+
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.base.ref == 'main') || (github.event_name != 'pull_request' && github.ref == 'refs/heads/main') }}
4545
run: |
4646
echo "image_tag=latest" >> $GITHUB_ENV
47-
- name: Extract env vars from tag
47+
- name: Extract env vars for other branches on PR
4848
shell: bash
49-
if: contains(github.ref, 'tags')
49+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'main' }}
5050
run: |
51-
tag=$(echo ${GITHUB_REF#refs/tags/})
52-
echo "image_tag=$tag" >> $GITHUB_ENV
53-
- name: Extract env vars from all other branches
51+
branch=${{ github.event.pull_request.base.ref }}
52+
branch_version="${branch#release/}"
53+
echo "image_tag=$branch_version" >> $GITHUB_ENV
54+
- name: Extract env vars for other branches on Push
5455
shell: bash
55-
if: contains(github.ref, 'refs/heads/main') == false && contains(github.ref, 'tags') == false
56+
if: ${{ github.event_name != 'pull_request' && contains(github.ref, 'refs/heads/main') == false }}
5657
run: |
5758
branch=$(echo ${GITHUB_REF#refs/heads/})
5859
branch_version="${branch#release/}"
5960
echo "image_tag=$branch_version" >> $GITHUB_ENV
6061
- name: Set outputs
6162
id: set-outputs
6263
run: |
63-
run: echo "image_tag=${{ env.image_tag }}" >> "$GITHUB_OUTPUT"
64+
echo "image_tag=${{ env.image_tag }}" >> "$GITHUB_OUTPUT"
6465
6566
run-e2e-ci:
6667
needs:

0 commit comments

Comments
 (0)