2929 do_not_skip : ' ["workflow_dispatch", "schedule", "push"]'
3030 concurrent_skipping : false
3131
32- lint :
33- runs-on : ubuntu-latest
34- needs : detect-noop
35- if : needs.detect-noop.outputs.noop != 'true' && github.ref != 'refs/heads/main'
36- steps :
37- - name : Checkout
38- uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
39-
40- - name : Lint Dockerfile
41- run : make lint
42-
43- unit-tests :
44- runs-on : ubuntu-latest
45- needs : detect-noop
46- if : needs.detect-noop.outputs.noop != 'true'
47- steps :
48- - name : Checkout
49- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
50-
51- - name : Run Unit Tests (Postgres)
52- run : make test.unit BACKEND=postgres IMAGE_NAME=alerta-test
53-
54- - name : Run Unit Tests (MongoDB)
55- run : make test.unit BACKEND=mongodb IMAGE_NAME=alerta-test
56-
5732 publish-artifacts :
58- needs : [lint, unit-tests]
5933 if : ${{ needs.detect-noop.outputs.noop != 'true' && startsWith(github.ref, 'refs/tags/workable-') }}
6034 permissions :
6135 id-token : write
6640 - name : Checkout
6741 uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6842
43+ - name : Check secrets availability
44+ id : secrets_check
45+ shell : bash
46+ run : |
47+ echo "has_sre=${{ secrets.SRE_GCR_SA != '' }}" >> $GITHUB_OUTPUT
48+ echo "has_staging=${{ secrets.STAGING_GCR_SA != '' }}" >> $GITHUB_OUTPUT
49+ echo "has_production=${{ secrets.PRODUCTION_GCR_SA != '' }}" >> $GITHUB_OUTPUT
50+
6951 - name : Get image tag
7052 id : container-info
7153 run : |
@@ -79,16 +61,27 @@ jobs:
7961 push : false
8062 tags : Workable/alerta-base:${{ steps.container-info.outputs.image-tag }}
8163 provenance : false
64+ build-args : |
65+ BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
66+ RELEASE=9.0.4
67+ VERSION=${{ steps.container-info.outputs.image-tag }}
8268
8369 # DISTRIBUTION OF SRE IMAGE
70+ - name : Skip SRE registry push
71+ if : ${{ steps.secrets_check.outputs.has_sre == 'false' }}
72+ run : |
73+ echo "::warning title=SRE Registry Push Skipped::The SRE_GCR_SA secret is missing. Skipping image push to SRE registry."
74+
8475 - name : Login to sre registry
76+ if : ${{ steps.secrets_check.outputs.has_sre == 'true' }}
8577 uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
8678 with :
8779 registry : us-docker.pkg.dev
8880 username : _json_key
8981 password : ${{ secrets.SRE_GCR_SA }}
9082
9183 - name : Push image to sre registry
84+ if : ${{ steps.secrets_check.outputs.has_sre == 'true' }}
9285 env :
9386 REGISTRY : us-docker.pkg.dev/sre-artifacts-20e4/gcr.io
9487 run : |
@@ -97,14 +90,21 @@ jobs:
9790 docker push ${{ env.REGISTRY }}/alerta-base:${{ steps.container-info.outputs.image-tag }}
9891
9992 # DISTRIBUTION OF STAGING IMAGE
93+ - name : Skip Staging registry push
94+ if : ${{ steps.secrets_check.outputs.has_staging == 'false' }}
95+ run : |
96+ echo "::warning title=Staging Registry Push Skipped::The STAGING_GCR_SA secret is missing. Skipping image push to Staging registry."
97+
10098 - name : Login to staging registry
99+ if : ${{ steps.secrets_check.outputs.has_staging == 'true' }}
101100 uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
102101 with :
103102 registry : us-docker.pkg.dev
104103 username : _json_key
105104 password : ${{ secrets.STAGING_GCR_SA }}
106105
107106 - name : Push image to staging registry
107+ if : ${{ steps.secrets_check.outputs.has_staging == 'true' }}
108108 env :
109109 REGISTRY : us-docker.pkg.dev/staging-artifacts-786a/gcr.io
110110 run : |
@@ -113,14 +113,21 @@ jobs:
113113 docker push ${{ env.REGISTRY }}/alerta-base:${{ steps.container-info.outputs.image-tag }}
114114
115115 # DISTRIBUTION OF PRODUCTION IMAGE
116+ - name : Skip Production registry push
117+ if : ${{ steps.secrets_check.outputs.has_production == 'false' }}
118+ run : |
119+ echo "::warning title=Production Registry Push Skipped::The PRODUCTION_GCR_SA secret is missing. Skipping image push to Production registry."
120+
116121 - name : Login to production registry
122+ if : ${{ steps.secrets_check.outputs.has_production == 'true' }}
117123 uses : docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
118124 with :
119125 registry : us-docker.pkg.dev
120126 username : _json_key
121127 password : ${{ secrets.PRODUCTION_GCR_SA }}
122128
123129 - name : Push image to production registry
130+ if : ${{ steps.secrets_check.outputs.has_production == 'true' }}
124131 env :
125132 REGISTRY : us-docker.pkg.dev/production-artifacts-0b0d/gcr.io
126133 run : |
0 commit comments