Skip to content

Commit 02ac15e

Browse files
committed
only trigger auto publish on PR is merged
1 parent 3eaaa30 commit 02ac15e

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

.github/workflows/tag-workflow.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
name: build for test/release
22

33
on:
4-
create:
5-
tags:
6-
- '**'
7-
pull_request:
8-
branches:
9-
- master
104
push:
11-
branches:
12-
- master
13-
- test*
5+
branches: ['prep/**', 'release/**', 'test/**', master, main]
6+
tags: ['**']
147
workflow_dispatch:
158
jobs:
169
build:
@@ -36,9 +29,15 @@ jobs:
3629
export job_url=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
3730
export oss_exists=0
3831
export ftp_exists=0
39-
export rx='^v([0-9]+\.){0,2}(\*|[0-9]+)(-rc[0-9]*){0,1}$'
40-
if [[ "${{github.ref_type}}" == "tag" ]] && [[ "${{github.event_name}}" == "create" ]] && [[ "$github_tag" =~ $rx ]]; then
41-
export pub_method=pushRelease
32+
export is_tag_create=false
33+
34+
export rx_tag='^refs\/tags\/.*'
35+
export rx_version_tag='^v([0-9]+\.){0,2}(\*|[0-9]+)(-rc[0-9]*){0,1}$'
36+
if [[ "${{github.ref}}" =~ $rx_tag ]]; then
37+
export is_tag_create=true
38+
if [[ "${{github.ref_name}}" =~ $rx_version_tag ]]; then
39+
export pub_method=pushRelease
40+
fi
4241
fi
4342
4443
if [[ "${{secrets.OSS_KEY_ID}}" != "" && \
@@ -50,6 +49,7 @@ jobs:
5049
if [[ "${{secrets.FTP_HOST}}" != "" ]]; then
5150
export ftp_exists=1
5251
fi
52+
5353
echo "::set-output name=commit::$commit"
5454
echo "::set-output name=short::$short"
5555
echo "::set-output name=github_tag::$github_tag"
@@ -60,6 +60,7 @@ jobs:
6060
echo "::set-output name=artifact_name::$artifact_name"
6161
echo "::set-output name=job_url::$job_url"
6262
echo "::set-output name=pub_method::$pub_method"
63+
echo "::set-output name=is_tag_create:$is_tag_create"
6364
echo "::set-output name=oss_exists::$oss_exists"
6465
echo "::set-output name=ftp_exists::$ftp_exists"
6566
@@ -79,6 +80,7 @@ jobs:
7980
echo secrets.godeye_url = ${{ secrets.GODEYE_URL }}
8081
echo vars.oss_exists = ${{steps.vars.outputs.oss_exists}}
8182
echo vars.ftp_exists = ${{steps.vars.outputs.ftp_exists}}
83+
echo vars.is_tag_create = ${{steps.vars.outputs.is_tag_create}}
8284
echo github.ref = ${{github.ref}}
8385
echo github.ref_name = ${{github.ref_name}}
8486
echo vars.job_url = ${{steps.vars.outputs.job_url}}
@@ -174,7 +176,7 @@ jobs:
174176
set -e
175177
176178
- name: Publish the Docker image
177-
if: ${{ github.ref_type == 'tag' && github.event_name == 'create' }}
179+
if: ${{ steps.vars.outputs.is_tag_create == 'true' }}
178180
run: |
179181
make docker-buildenv
180182
make docker-runtime

0 commit comments

Comments
 (0)