3232 push-release-image :
3333 name : Build and Push Multi-Arch Image
3434 runs-on : ubuntu-latest
35- permissions :
36- packages : write # Needed to push images to GHCR
35+ permissions :
36+ contents : read
37+ id-token : write
3738 needs : [build-amd64, build-arm64, build-arm]
3839 steps :
3940 - name : Checkout code
@@ -42,12 +43,31 @@ jobs:
4243 - name : Set up Docker Buildx
4344 uses : docker/setup-buildx-action@v3
4445
46+ - name : Read registry secrets (staging)
47+ uses : rancher-eio/read-vault-secrets@main
48+ if : ${{ github.event.release.prerelease }}
49+ with :
50+ secrets : |
51+ secret/data/github/repo/${{ github.repository }}/k3s-suse-registry-stg/credentials registry | REGISTRY ;
52+ secret/data/github/repo/${{ github.repository }}/k3s-suse-registry-stg/credentials username | REGISTRY_USERNAME ;
53+ secret/data/github/repo/${{ github.repository }}/k3s-suse-registry-stg/credentials password | REGISTRY_PASSWORD
54+
55+ - name : Read registry secrets (prime)
56+ uses : rancher-eio/read-vault-secrets@main
57+ if : ${{ ! github.event.release.prerelease }}
58+ with :
59+ secrets : |
60+ secret/data/github/repo/${{ github.repository }}/k3s-suse-registry/credentials registry | REGISTRY ;
61+ secret/data/github/repo/${{ github.repository }}/k3s-suse-registry/credentials username | REGISTRY_USERNAME ;
62+ secret/data/github/repo/${{ github.repository }}/k3s-suse-registry/credentials password | REGISTRY_PASSWORD
63+
64+
4565 - name : Log in to GitHub Container Registry
4666 uses : docker/login-action@v3
4767 with :
48- registry : ghcr.io
49- username : ${{ github.repository_owner }}
50- password : ${{ secrets.GITHUB_TOKEN }}
68+ registry : ${{ env.REGISTRY }}
69+ username : ${{ env.REGISTRY_USERNAME }}
70+ password : ${{ env.REGISTRY_PASSWORD }}
5171
5272 - name : Configure image tags
5373 id : tag_config
7292 uses : docker/metadata-action@v5
7393 with :
7494 images : |
75- ghcr.io/ ${{ github.repository_owner }}/k3s
95+ ${{ env.REGISTRY }}/rancher /k3s
7696 flavor : latest=false
7797 tags : ${{ steps.tag_config.outputs.tag_spec }}
7898
@@ -104,7 +124,8 @@ jobs:
104124 name : Build Airgap Pkg (${{ matrix.arch }})
105125 runs-on : ubuntu-latest # Runs on standard runner, docker pulls with --platform
106126 permissions :
107- contents : write # Needed to update release with assets
127+ contents : read
128+ id-token : write
108129 strategy :
109130 matrix :
110131 arch : [amd64, arm64, arm]
@@ -113,6 +134,21 @@ jobs:
113134 - name : Checkout code
114135 uses : actions/checkout@v4
115136
137+ - name : Read Prime artifacts secrets
138+ uses : rancher-eio/read-vault-secrets@main
139+ with :
140+ secrets : |
141+ secret/data/github/repo/${{ github.repository }}/rancher-prime-artifacts/credentials accessKeyId | AWS_ACCESS_KEY_ID ;
142+ secret/data/github/repo/${{ github.repository }}/rancher-prime-artifacts/credentials secretAccessKey | AWS_SECRET_ACCESS_KEY ;
143+ secret/data/github/repo/${{ github.repository }}/rancher-prime-artifacts/credentials primeArtifactsBucketName | PRIME_ARTIFACTS_BUCKET_NAME
144+
145+ - name : Configure AWS Credentials (s3)
146+ uses : aws-actions/configure-aws-credentials@v4
147+ with :
148+ aws-access-key-id : ${{ env.AWS_ACCESS_KEY_ID }}
149+ aws-secret-access-key : ${{ env.AWS_SECRET_ACCESS_KEY }}
150+ aws-region : us-east-1
151+
116152 - name : Set up Docker Buildx
117153 uses : docker/setup-buildx-action@v3
118154
@@ -133,35 +169,38 @@ jobs:
133169 name : k3s-airgap-images-${{ matrix.arch }}.sha256sum
134170 path : dist/artifacts/k3s-airgap-images-${{ matrix.arch }}.sha256sum
135171
136- - name : Upload k3s-images.txt to Release
137- uses : softprops/action-gh-release@v2
138- # This action is recommended by GITHUB, they don't support a first party action for releases
139- # See https://github.com/actions/create-release?tab=readme-ov-file#github-action---releases-api
140- if : ${{ matrix.arch == 'amd64' }}
141- with :
142- files : |
143- dist/artifacts/k3s-images.txt
172+ - name : Upload Assets
144173 env :
145- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
146-
147- - name : Upload Airgap Assets to Release
148- uses : softprops/action-gh-release@v2
149- with :
150- files : |
151- dist/artifacts/k3s-airgap-images*
152- env :
153- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
174+ S3_PATH : s3://${{ env.PRIME_ARTIFACTS_BUCKET_NAME }}/k3s/${{ github.event.release.tag_name }}
175+ run : |
176+ aws s3 sync dist/artifacts/ "$S3_PATH" --quiet --no-progress --exclude "*" --include "k3s-images.txt" --include "k3s-airgap-images*"
154177
155178 upload-release-assets :
156179 name : Prepare and Upload Release Assets
157180 permissions :
158- contents : write # Needed to update release with assets
181+ contents : read
182+ id-token : write
159183 runs-on : ubuntu-latest
160184 needs : [build-amd64, build-arm64, build-arm, upload-release-airgap]
161185 steps :
162186 - name : Checkout code
163187 uses : actions/checkout@v4
164188
189+ - name : Read Prime artifacts secrets
190+ uses : rancher-eio/read-vault-secrets@main
191+ with :
192+ secrets : |
193+ secret/data/github/repo/${{ github.repository }}/prime-artifacts-uploader/credentials accessKeyId | AWS_ACCESS_KEY_ID ;
194+ secret/data/github/repo/${{ github.repository }}/prime-artifacts-uploader/credentials secretAccessKey | AWS_SECRET_ACCESS_KEY ;
195+ secret/data/github/repo/${{ github.repository }}/prime-artifacts-uploader/credentials primeArtifactsBucketName | PRIME_ARTIFACTS_BUCKET_NAME
196+
197+ - name : Configure AWS Credentials (s3)
198+ uses : aws-actions/configure-aws-credentials@v4
199+ with :
200+ aws-access-key-id : ${{ env.AWS_ACCESS_KEY_ID }}
201+ aws-secret-access-key : ${{ env.AWS_SECRET_ACCESS_KEY }}
202+ aws-region : us-east-1
203+
165204 - name : " Download Binaries and Airgap sha256sum"
166205 uses : actions/download-artifact@v4
167206 with :
@@ -184,12 +223,8 @@ jobs:
184223 fi
185224 done
186225
187- - name : Upload Assets to Release
188- 189- with :
190- files : |
191- dist/artifacts/k3s*
192- dist/artifacts/sha256sum*
226+ - name : Upload Assets
193227 env :
194- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
195-
228+ S3_PATH : s3://${{ env.PRIME_ARTIFACTS_BUCKET_NAME }}/k3s/${{ github.event.release.tag_name }}
229+ run : |
230+ aws s3 sync dist/artifacts/ "$S3_PATH" --quiet --no-progress --exclude "*" --include "k3s*" --include "sha256sum*"
0 commit comments