11name : stacks-blockchain
22
33# Only run when:
4- # - tags starting with "v" get pushed
54# - PRs are opened against the master branch
65# - the workflow is started from the UI (an optional tag can be passed in via parameter)
76# - If the optional tag parameter is passed in, a new tag will be generated based off the selected branch
87on :
9- push :
10- tags :
11- - ' v*'
128 pull_request :
139 workflow_dispatch :
1410 inputs :
5854 # Run net-tests
5955 nettest :
6056 runs-on : ubuntu-latest
61- if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
6257 steps :
6358 - uses : actions/checkout@v2
6459 - name : Run network relay tests
@@ -109,6 +104,11 @@ jobs:
109104 runs-on : ubuntu-latest
110105 steps :
111106 - uses : actions/checkout@v2
107+ - name : Set Vars
108+ run : |
109+ echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
110+ echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
111+
112112 - name : Build/Tag/Push Image
113113 uses : docker/build-push-action@v1
114114 with :
@@ -118,8 +118,9 @@ jobs:
118118 tags : ${{ github.event.inputs.tag }}
119119 tag_with_ref : true
120120 add_git_labels : true
121- # Only push if (a tag was passed in) or (we're building a tag) or (we're building a non-master branch which isn't a PR)
122- push : ${{ github.event.inputs.tag != '' || contains(github.ref, 'refs/tags') || (github.ref != 'refs/heads/master' && !contains(github.ref, 'refs/pull')) }}
121+ build_args : STACKS_NODE_VERSION=${{ github.event.inputs.tag || env.GITHUB_SHA_SHORT }},GIT_BRANCH=${{ env.GITHUB_REF_SHORT }},GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
122+ # Only push if (a tag was passed in) or (we're building a non-master branch which isn't a PR)
123+ push : ${{ github.event.inputs.tag != '' || (github.ref != 'refs/heads/master' && !contains(github.ref, 'refs/pull')) }}
123124
124125 # Build docker image, tag it with the git tag and `latest` if running on master branch, and publish under the following conditions
125126 # Will publish if:
@@ -146,6 +147,11 @@ jobs:
146147 env :
147148 TAG : ${{ github.event.inputs.tag }}
148149
150+ - name : Set Vars
151+ run : |
152+ echo "GITHUB_SHA_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
153+ echo "GITHUB_REF_SHORT=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
154+
149155 - name : Build/Tag/Push Image
150156 uses : docker/build-push-action@v1
151157 with :
@@ -156,13 +162,14 @@ jobs:
156162 tags : ${{ env.STRETCH_TAG }}
157163 tag_with_ref : false
158164 add_git_labels : true
159- # Only push if (a tag was passed in) or (we're building a tag) or (we're building a non-master branch which isn't a PR)
160- push : ${{ github.event.inputs.tag != '' || contains(github.ref, 'refs/tags') || (github.ref != 'refs/heads/master' && !contains(github.ref, 'refs/pull')) }}
165+ build_args : STACKS_NODE_VERSION=${{ github.event.inputs.tag || env.GITHUB_SHA_SHORT }},GIT_BRANCH=${{ env.GITHUB_REF_SHORT }},GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
166+ # Only push if (a tag was passed in) or (we're building a non-master branch which isn't a PR)
167+ push : ${{ github.event.inputs.tag != '' || (github.ref != 'refs/heads/master' && !contains(github.ref, 'refs/pull')) }}
161168
162- # Create a new release if we're building a tag or a tag was passed in
169+ # Create a new release if we're building a tag
163170 create-release :
164171 runs-on : ubuntu-latest
165- if : ${{ github.event.inputs.tag != '' || contains(github.ref, 'refs/tags') }}
172+ if : ${{ github.event.inputs.tag != '' }}
166173 outputs :
167174 upload_url : ${{ steps.create_release.outputs.upload_url }}
168175 needs :
@@ -187,7 +194,7 @@ jobs:
187194 # Upload distributables to a new release if we're building a tag or a tag was passed in
188195 upload-dist :
189196 runs-on : ubuntu-latest
190- if : ${{ github.event.inputs.tag != '' || contains(github.ref, 'refs/tags') }}
197+ if : ${{ github.event.inputs.tag != '' }}
191198 needs :
192199 - create-release
193200 strategy :
0 commit comments