Skip to content

Commit 2755a10

Browse files
authored
find branch name through github (ITISFoundation#2889)
1 parent 6c1c013 commit 2755a10

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

.github/workflows/ci-release.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
- uses: actions/checkout@v3
3333
with:
3434
fetch-depth: 0
35-
- name: set target variable
36-
run: |
37-
target=$(git name-rev --refs="refs/remotes/origin/*" --name-only ${GITHUB_SHA})
38-
echo "TARGET=${target}" >> $GITHUB_ENV
35+
- name: find branch name
36+
shell: bash
37+
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
38+
3939
- name: setup docker buildx
4040
id: buildx
4141
uses: docker/setup-buildx-action@v1
@@ -48,12 +48,15 @@ jobs:
4848
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
4949
- name: set git tag
5050
run: echo "GIT_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
51-
- if: contains(env.TARGET, 'remotes/origin/master')
51+
- name: show system environs
52+
if: github.event_name == 'push'
53+
run: ./ci/helpers/show_system_versions.bash
54+
- if: contains(env.BRANCH_NAME, 'master')
5255
env:
5356
FROM_TAG_PREFIX: staging-github
5457
name: deploy
5558
run: ./ci/deploy/dockerhub-tag-version.bash
56-
- if: contains(env.TARGET, 'remotes/origin/hotfix_v')
59+
- if: contains(env.BRANCH_NAME, 'hotfix_v')
5760
env:
5861
FROM_TAG_PREFIX: hotfix-github
5962
name: deploy from hotfix image

.github/workflows/ci-staging.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131
- uses: actions/checkout@v3
3232
with:
3333
fetch-depth: 0
34-
- name: set target variable
35-
run: |
36-
target=$(git name-rev --refs="refs/remotes/origin/*" --name-only ${GITHUB_SHA})
37-
echo "TARGET=${target}" >> $GITHUB_ENV
34+
- name: find branch name
35+
shell: bash
36+
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
37+
3838
- name: setup docker buildx
3939
id: buildx
4040
uses: docker/setup-buildx-action@v1
@@ -47,12 +47,15 @@ jobs:
4747
run: echo "OWNER=${GITHUB_REPOSITORY%/*}" >> $GITHUB_ENV
4848
- name: set git tag
4949
run: echo "GIT_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
50-
- if: contains(env.TARGET, 'remotes/origin/master')
50+
- name: show system environs
51+
if: github.event_name == 'push'
52+
run: ./ci/helpers/show_system_versions.bash
53+
- if: contains(env.BRANCH_NAME, 'master')
5154
env:
5255
FROM_TAG_PREFIX: master-github
5356
name: deploy from master to staging
5457
run: ./ci/deploy/dockerhub-tag-version.bash
55-
- if: contains(env.TARGET, 'remotes/origin/hotfix_staging_')
58+
- if: contains(env.BRANCH_NAME, 'hotfix_staging_')
5659
env:
5760
FROM_TAG_PREFIX: hotfix-staging-github
5861
name: deploy from hotfix staging to staging

0 commit comments

Comments
 (0)