@@ -2,11 +2,14 @@ name: Publish Docker image
22on :
33 workflow_dispatch :
44 push :
5- branches : [main, dev, support/v1]
5+ tags : ["v*"]
6+ branches : [main, support/v1]
67 paths : ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
8+ pull_request :
79env :
810 REGISTRY : msgraphprod.azurecr.io
911 IMAGE_NAME : public/openapi/hidi
12+ PREVIEW_BRANCH : " refs/heads/main"
1013jobs :
1114 push_to_registry :
1215 environment :
@@ -28,14 +31,24 @@ jobs:
2831 echo "::set-output name=version::${version}"
2932 shell: pwsh
3033 id: getversion
34+ - name : Get truncated run number
35+ if : contains(github.ref, env.PREVIEW_BRANCH)
36+ id : runnumber
37+ run : echo "runnumber=$(echo ${{ github.run_number }} | awk '{ print substr($0, length($0)-3, length($0)) }')" >> $GITHUB_OUTPUT
38+ - name : Get current date
39+ if : contains(github.ref, env.PREVIEW_BRANCH)
40+ id : date
41+ run : echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
3142 - name : Push to registry - Nightly
32- if : ${{ github.ref == 'refs/heads/dev' }}
43+ if : contains( github.ref, env.PREVIEW_BRANCH)
33443445 with :
3546 push : true
36- tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
47+ 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 }}
48+ build-args : |
49+ version_suffix=preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
3750 - name : Push to registry - Release
38- if : ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/support/v1' }}
51+ if : contains( github.ref, 'refs/tags/v')
39524053 with :
4154 push : true
0 commit comments