@@ -2,11 +2,13 @@ name: Publish Docker image
2
2
on :
3
3
workflow_dispatch :
4
4
push :
5
- branches : [main, dev, support/v1]
6
- paths : ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
5
+ tags : ["v*"]
6
+ branches : [main]
7
+ pull_request :
7
8
env :
8
9
REGISTRY : msgraphprod.azurecr.io
9
10
IMAGE_NAME : public/openapi/hidi
11
+ PREVIEW_BRANCH : " refs/heads/main"
10
12
jobs :
11
13
push_to_registry :
12
14
environment :
@@ -28,14 +30,24 @@ jobs:
28
30
echo "::set-output name=version::${version}"
29
31
shell: pwsh
30
32
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
31
41
- name : Push to registry - Nightly
32
- if : ${{ github.ref == 'refs/heads/dev' }}
42
+ if : contains( github.ref, env.PREVIEW_BRANCH)
33
43
34
44
with :
35
45
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 }}
37
49
- 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')
39
51
40
52
with :
41
53
push : true
0 commit comments