@@ -2,11 +2,13 @@ name: Publish Docker image
22on :
33 workflow_dispatch :
44 push :
5- branches : [main, dev, support/v1]
6- paths : ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
5+ tags : ["v*"]
6+ branches : [main]
7+ pull_request :
78env :
89 REGISTRY : msgraphprod.azurecr.io
910 IMAGE_NAME : public/openapi/hidi
11+ PREVIEW_BRANCH : " refs/heads/main"
1012jobs :
1113 push_to_registry :
1214 environment :
@@ -28,14 +30,24 @@ jobs:
2830 echo "::set-output name=version::${version}"
2931 shell: pwsh
3032 id: getversion
33+ - name : Get truncated run number
34+ if : contains(github.ref, env.PREVIEW_BRANCH)
35+ id : runnumber
36+ run : echo "runnumber=$(echo ${{ github.run_number }} | awk '{ print substr($0, length($0)-3, length($0)) }')" >> $GITHUB_OUTPUT
37+ - name : Get current date
38+ if : contains(github.ref, env.PREVIEW_BRANCH)
39+ id : date
40+ run : echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
3141 - name : Push to registry - Nightly
32- if : ${{ github.ref == 'refs/heads/dev' }}
42+ if : contains( github.ref, env.PREVIEW_BRANCH)
33433444 with :
3545 push : true
36- tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
46+ tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}-preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
47+ build-args : |
48+ version_suffix=preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
3749 - name : Push to registry - Release
38- if : ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/support/v1' }}
50+ if : contains( github.ref, 'refs/tags/v')
39514052 with :
4153 push : true
0 commit comments