@@ -53,12 +53,16 @@ jobs:
5353 needs : [setup]
5454 runs-on : ubuntu-latest
5555 outputs :
56+ image-version : ${{ steps.build-artifact.outputs.image-version }}
5657 fingerprint : ${{ steps.calculate_fingerprint.outputs.fingerprint }}
5758 steps :
5859 - uses : actions/checkout@v4
5960
6061 - name : Build backend
61- run : echo "Here we could do some proper build"
62+ id : build-artifact
63+ run : |
64+ echo "Here we could do some proper build"
65+ echo "image-version=${{ env.KOSLI_TRAIL }}" >> $GITHUB_OUTPUT
6266
6367 - name : Extract short SHA
6468 run : echo "SHORT_SHA=${GITHUB_SHA:0:7}" >> $GITHUB_ENV
9397 uses : ./.github/workflows/_deploy.yml
9498 with :
9599 environment : Development
96- version : xxx
100+ version : ${{ needs.build.outputs.image-version }}
97101 resource : dev-backend
98102 secrets : inherit
99103
@@ -105,25 +109,49 @@ jobs:
105109 uses : ./.github/workflows/_deploy.yml
106110 with :
107111 environment : Stage
108- version : xxx
112+ version : ${{ needs.build.outputs.image-version }}
109113 resource : stage-backend
110114 secrets : inherit
111115
112- # assert-artifacts:
113- # name: Assert artifacts
114- # if: ${{ github.ref == 'refs/heads/main' && always() }}
115- # needs: [build, pull-request]
116- # runs-on: ubuntu-latest
117- # steps:
118- # - name: Setup Kosli cli
119- # uses: kosli-dev/setup-cli-action@v2
120- # with:
121- # version:
122- # ${{ vars.KOSLI_CLI_VERSION }}
123- #
124- # - name: Assert Artifacts
125- # run: |
126- # set -x
127- # EXIT_CODE=0
128- # kosli assert artifact --fingerprint ${{ needs.build.outputs.fingerprint }} || EXIT_CODE=1
129- # exit ${EXIT_CODE}
116+
117+ semver-tag :
118+ needs : [build,deploy-stage]
119+ name : Check for semver tag
120+ runs-on : ubuntu-latest
121+ outputs :
122+ release-to-prod : ${{ steps.check-tag.outputs.match }}
123+ steps :
124+ - name : Check Tag
125+ id : check-tag
126+ run : |
127+ if [[ ${{ github.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
128+ echo "match=true" >> $GITHUB_OUTPUT
129+ fi
130+
131+
132+ assert-artifact :
133+ name : Assert artifacts
134+ if : ${{ github.ref == 'refs/heads/main' && always() }}
135+ needs : [build, pull-request, deploy-stage]
136+ runs-on : ubuntu-latest
137+ steps :
138+ - name : Setup Kosli cli
139+ uses : kosli-dev/setup-cli-action@v2
140+ with :
141+ version :
142+ ${{ vars.KOSLI_CLI_VERSION }}
143+
144+ - name : Assert Artifacts
145+ run : |
146+ kosli assert artifact --fingerprint ${{ needs.build.outputs.fingerprint }}
147+
148+ deploy-production :
149+ if : ${{ (github.event_name != 'workflow_dispatch' && needs.semver-tag.outputs.release-to-prod == 'true') }}
150+ needs : [build,deploy-stage,semver-tag,assert-artifact]
151+ name : Deploy to production
152+ uses : ./.github/workflows/_deploy.yml
153+ with :
154+ environment : Production
155+ version : ${{ needs.build.outputs.image-version }}
156+ resource : prod-backend
157+ secrets : inherit
0 commit comments