Skip to content

Commit 80a4ea6

Browse files
authored
refactor: simplify build workflow (#245)
* refactor: merge build workflows * refactor: rename build workflows * feat: build sub-branches * fix: regex, support slash (convert to dash) * fix: wrong tag for docker * chore: restore regex, which was okay
1 parent bf3f940 commit 80a4ea6

File tree

2 files changed

+26
-65
lines changed

2 files changed

+26
-65
lines changed

.github/workflows/build-pprd.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: DS User Guide Builds
1+
name: Build and Push
22

33
on:
44
workflow_dispatch:
@@ -11,6 +11,10 @@ on:
1111
push:
1212
branches:
1313
- main
14+
- pprd
15+
- epic/v3
16+
- epic/v3--*
17+
- any/branch-you-want
1418

1519
jobs:
1620
docker:
@@ -32,13 +36,30 @@ jobs:
3236
echo ::set-output name=ref_short::${SHORT_REF}
3337
env:
3438
EVENT_SHA: ${{ github.event.client_payload.sha }}
35-
- name: Print vars
39+
-
40+
name: Determine environment tag
41+
id: env_tag
42+
run: |
43+
if [ -n "${{ inputs.tag_custom }}" ]; then
44+
ENV_TAG="${{ inputs.tag_custom }}"
45+
elif [ "${{ github.ref_name }}" = "main" ]; then
46+
ENV_TAG="latest"
47+
elif [ "${{ github.ref_name }}" = "pprd" ]; then
48+
ENV_TAG="pprd"
49+
else
50+
ENV_TAG="${{ steps.vars.outputs.ref_short }}"
51+
fi
52+
echo ::set-output name=env_tag::${ENV_TAG}
53+
-
54+
name: Print vars
3655
run: |
37-
echo $SHORT_SHA
38-
echo $SHORT_REF
56+
echo "Short SHA: $SHORT_SHA"
57+
echo "Short Ref: $SHORT_REF"
58+
echo "Environment Tag: $ENV_TAG"
3959
env:
4060
SHORT_SHA: ${{ steps.vars.outputs.sha_short }}
4161
SHORT_REF: ${{ steps.vars.outputs.ref_short }}
62+
ENV_TAG: ${{ steps.env_tag.outputs.env_tag }}
4263
-
4364
name: Login to Docker Hub
4465
uses: docker/login-action@v2
@@ -50,7 +71,7 @@ jobs:
5071
uses: docker/build-push-action@v3
5172
with:
5273
push: true
53-
tags: designsafeci/ds-user-guide:${{ inputs.tag_custom && inputs.tag_custom || 'latest' }},designsafeci/ds-user-guide:${{ steps.vars.outputs.sha_short }},designsafeci/ds-user-guide:${{ steps.vars.outputs.ref_short }}
74+
tags: designsafeci/ds-user-guide:${{ steps.env_tag.outputs.env_tag }},designsafeci/ds-user-guide:${{ steps.vars.outputs.sha_short }},designsafeci/ds-user-guide:${{ steps.vars.outputs.ref_short }}
5475
-
5576
name: Post build status in slack
5677
id: slack

0 commit comments

Comments
 (0)