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