1- name : installer- image
1+ name : image
22
33on :
44 push :
5- tags : ["installer -v*"]
5+ tags : ["image -v*"]
66 branches :
77 - main
88 pull_request :
99 branches :
1010 - main
1111
1212permissions :
13- contents : read
1413 packages : write
14+ pull-requests : write
1515
1616jobs :
1717 build-installer-image :
@@ -24,11 +24,69 @@ jobs:
2424 username : ${{ github.repository_owner }}
2525 password : ${{ secrets.GITHUB_TOKEN }}
2626 - uses : actions/checkout@v2
27+ # set image version based on event type
28+ - name : get version from tag
29+ if : ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
30+ run : |
31+ $imageversion=$env:GITHUB_REF_NAME -replace "image-", ""
32+ "IMAGE_VERSION=$imageversion" >> $env:GITHUB_ENV
33+ - name : get version for PR
34+ if : ${{ github.event_name == 'pull_request' }}
35+ run : |
36+ "IMAGE_VERSION=pr-${{ github.event.number }}" >> $env:GITHUB_ENV
37+ # build and publish image
38+ # need to always publish this image so can use it to build the debug image for verification
2739 - name : build image
2840 run : |
29- .\build-installer.ps1 -version $env:GITHUB_REF_NAME
41+ echo $env:IMAGE_VERSION
42+ .\build-installer.ps1 -version $env:IMAGE_VERSION
3043 - name : push image
31- if : ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
3244 run : |
33- $tag=$env:GITHUB_REF_NAME
45+ echo $env:IMAGE_VERSION
46+ $tag=$env:IMAGE_VERSION
3447 docker image push ghcr.io/jsturtevant/debug-installer:$tag
48+ - name : comment on PR
49+ if : ${{ github.event_name == 'pull_request' }}
50+ env :
51+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52+ run : |
53+ $comment=@"
54+ Thank you for the contribution :rocket: The debug installer cache image has been published to a temporary repository.
55+
56+ You can use it by referencing: ``ghcr.io/jsturtevant/debug-installer:$env:IMAGE_VERSION``.
57+
58+ It will be removed in 24 hours.
59+ "@
60+
61+ gh api --method POST -H "Accept: application/vnd.github+json" /repos/jsturtevant/windows-debug/issues/${{ github.event.pull_request.number }}/comments -f body="$comment"
62+ build-debug-image :
63+ needs : build-installer-image
64+ runs-on : ubuntu-latest
65+ steps :
66+ - name : login to GitHub container registry
67+ uses : docker/login-action@v1
68+ with :
69+ registry : ghcr.io
70+ username : ${{ github.repository_owner }}
71+ password : ${{ secrets.GITHUB_TOKEN }}
72+ - uses : actions/checkout@v2
73+ # set image version based on event type
74+ - name : get version from tag
75+ if : ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
76+ run : |
77+ imageversion=echo $GITHUB_REF_NAME | sed 's/^image-//'
78+ echo "IMAGE_VERSION=$imageversion" >> $GITHUB_ENV
79+ - name : get version for PR
80+ if : ${{ github.event_name == 'pull_request' }}
81+ run : |
82+ echo "IMAGE_VERSION=pr-${{ github.event.number }}" >> $GITHUB_ENV
83+ # build and publish image
84+ - name : build image
85+ run : |
86+ echo $IMAGE_VERSION
87+ sudo VERSION=$IMAGE_VERSION INSTALLER_VERSION=$IMAGE_VERSION ./build.sh
88+ - name : push image
89+ if : ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
90+ run : |
91+ echo $IMAGE_VERSION
92+ OUTPUT=registry VERSION=$IMAGE_VERSION INSTALLER_VERSION=$IMAGE_VERSION ./build.sh
0 commit comments