99 # Run tests for any PRs.
1010 pull_request :
1111
12- permissions :
13- contents : read
12+ concurrency :
13+ group : ${{ github.workflow }}-${{ github.ref }}
14+ cancel-in-progress : true
15+
16+ permissions : {}
1417
1518jobs :
16- docker :
19+ set-vars :
20+ permissions :
21+ contents : read
1722 runs-on : ubuntu-latest
23+ outputs :
24+ controller-meta-tags : ${{ steps.controller-meta.outputs.tags }}
25+ plugin-meta-tags : ${{ steps.plugin-meta.outputs.tags }}
26+ platforms : ${{ steps.platform-matrix.outputs.platform-matrix }}
1827
1928 steps :
20- - name : Checkout
21- uses : actions/checkout@v3.1.0
22-
23- - name : Set up QEMU
24- uses : docker/setup-qemu-action@v2
25-
26- - name : Set up Docker Buildx
27- uses : docker/setup-buildx-action@v2
28- with :
29- config-inline : |
30- [worker.oci]
31- gc = false
32-
3329 - name : Docker meta (controller)
3430 id : controller-meta
3531 uses : docker/metadata-action@v4
3632 with :
3733 images : |
3834 quay.io/argoproj/argo-rollouts
39- # ghcr.io/argoproj/argo-rollouts
4035 tags : |
41- type=ref,event=branch
42- flavor : |
43- latest=${{ github.ref == 'refs/heads/master' }}
36+ type=ref,event=branch,enable=${{ github.ref != 'refs/heads/master'}}
37+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
4438
4539 - name : Docker meta (plugin)
4640 id : plugin-meta
4741 uses : docker/metadata-action@v4
4842 with :
4943 images : |
5044 quay.io/argoproj/kubectl-argo-rollouts
51- # ghcr.io/argoproj/kubectl-argo-rollouts
5245 tags : |
53- type=ref,event=branch
54- flavor : |
55- latest=${{ github.ref == 'refs/heads/master' }}
56-
57- # - name: Login to GitHub Container Registry
58- # if: github.event_name != 'pull_request'
59- # uses: docker/login-action@v2
60- # with:
61- # registry: ghcr.io
62- # username: ${{ github.repository_owner }}
63- # password: ${{ secrets.GITHUB_TOKEN }}
64-
65- - name : Login to Quay.io
66- if : github.event_name != 'pull_request'
67- uses : docker/login-action@v2
68- with :
69- registry : quay.io
70- username : ${{ secrets.QUAY_USERNAME }}
71- password : ${{ secrets.QUAY_ROBOT_TOKEN }}
46+ type=ref,event=branch,enable=${{ github.ref != 'refs/heads/master'}}
47+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
7248
7349 # avoid building linux/arm64 for PRs since it takes so long
7450 - name : Set Platform Matrix
@@ -79,73 +55,39 @@ jobs:
7955 then
8056 PLATFORM_MATRIX=$PLATFORM_MATRIX,linux/arm64
8157 fi
82- echo "::set-output name=platform-matrix::$PLATFORM_MATRIX"
83-
84- - name : Build and push (controller-image)
85- uses : docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
86- with :
87- platforms : ${{ steps.platform-matrix.outputs.platform-matrix }}
88- push : ${{ github.event_name != 'pull_request' }}
89- tags : ${{ steps.controller-meta.outputs.tags }}
90- provenance : false
91- sbom : false
92-
93- - name : Build and push (plugin-image)
94- uses : docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
95- with :
96- target : kubectl-argo-rollouts
97- platforms : ${{ steps.platform-matrix.outputs.platform-matrix }}
98- push : ${{ github.event_name != 'pull_request' }}
99- tags : ${{ steps.plugin-meta.outputs.tags }}
100- provenance : false
101- sbom : false
102-
103- - name : Install cosign
104- uses : sigstore/cosign-installer@main
105- with :
106- cosign-release : ' v1.13.1'
107-
108- - name : Install crane to get digest of image
109- uses : imjasonh/setup-crane@v0.3
110-
111- - name : Get digest of controller-image
112- run : |
113- if [[ "${{ github.ref == 'refs/heads/master' }}" ]]
114- then
115- echo "CONTROLLER_DIGEST=$(crane digest quay.io/argoproj/argo-rollouts:latest)" >> $GITHUB_ENV
116- fi
117- if [[ "${{ github.ref != 'refs/heads/master' }}" ]]
118- then
119- echo "CONTROLLER_DIGEST=$(crane digest ${{ steps.controller-meta.outputs.tags }})" >> $GITHUB_ENV
120- fi
121- if : github.event_name != 'pull_request'
122-
123- - name : Get digest of plugin-image
124- run : |
125- if [[ "${{ github.ref == 'refs/heads/master' }}" ]]
126- then
127- echo "PLUGIN_DIGEST=$(crane digest quay.io/argoproj/kubectl-argo-rollouts:latest)" >> $GITHUB_ENV
128- fi
129- if [[ "${{ github.ref != 'refs/heads/master' }}" ]]
130- then
131- echo "PLUGIN_DIGEST=$(crane digest ${{ steps.plugin-meta.outputs.tags }})" >> $GITHUB_ENV
132- fi
133- if : github.event_name != 'pull_request'
134-
135- - name : Sign Argo Rollouts Images
136- run : |
137- cosign sign --key env://COSIGN_PRIVATE_KEY quay.io/argoproj/argo-rollouts@${{ env.CONTROLLER_DIGEST }}
138- cosign sign --key env://COSIGN_PRIVATE_KEY quay.io/argoproj/kubectl-argo-rollouts@${{ env.PLUGIN_DIGEST }}
139- env :
140- COSIGN_PRIVATE_KEY : ${{secrets.COSIGN_PRIVATE_KEY}}
141- COSIGN_PASSWORD : ${{secrets.COSIGN_PASSWORD}}
142- if : ${{ github.event_name == 'push' }}
143-
144- - name : Display the public key to share.
145- run : |
146- # Displays the public key to share
147- cosign public-key --key env://COSIGN_PRIVATE_KEY
148- env :
149- COSIGN_PRIVATE_KEY : ${{secrets.COSIGN_PRIVATE_KEY}}
150- COSIGN_PASSWORD : ${{secrets.COSIGN_PASSWORD}}
151- if : ${{ github.event_name == 'push' }}
58+ echo "platform-matrix=$PLATFORM_MATRIX" >> $GITHUB_OUTPUT
59+
60+ build-and-push-controller-image :
61+ needs : [set-vars]
62+ permissions :
63+ contents : read
64+ packages : write # for pushing packages to GHCR, which is used by cd.apps.argoproj.io to avoid polluting Quay with tags
65+ id-token : write # for creating OIDC tokens for signing.
66+ uses : ./.github/workflows/image-reuse.yaml
67+ with :
68+ quay_image_name : ${{ needs.set-vars.outputs.controller-meta-tags }}
69+ # Note: cannot use env variables to set go-version (https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations)
70+ go-version : 1.19
71+ platforms : ${{ needs.set-vars.outputs.platforms }}
72+ push : ${{ github.event_name != 'pull_request' }}
73+ secrets :
74+ quay_username : ${{ secrets.QUAY_USERNAME }}
75+ quay_password : ${{ secrets.QUAY_ROBOT_TOKEN }}
76+
77+ build-and-push-plugin-image :
78+ needs : [set-vars]
79+ permissions :
80+ contents : read
81+ packages : write # for pushing packages to GHCR, which is used by cd.apps.argoproj.io to avoid polluting Quay with tags
82+ id-token : write # for creating OIDC tokens for signing.
83+ uses : ./.github/workflows/image-reuse.yaml
84+ with :
85+ quay_image_name : ${{ needs.set-vars.outputs.plugin-meta-tags }}
86+ # Note: cannot use env variables to set go-version (https://docs.github.com/en/actions/using-workflows/reusing-workflows#limitations)
87+ go-version : 1.19
88+ platforms : ${{ needs.set-vars.outputs.platforms }}
89+ push : ${{ github.event_name != 'pull_request' }}
90+ target : kubectl-argo-rollouts
91+ secrets :
92+ quay_username : ${{ secrets.QUAY_USERNAME }}
93+ quay_password : ${{ secrets.QUAY_ROBOT_TOKEN }}
0 commit comments