Skip to content

Commit 9f0244d

Browse files
recreate flow under new file name, and title
1 parent 3909af5 commit 9f0244d

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

.github/workflows/release.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
## (5b) Pin to commits, not tags
2+
3+
name: CI Build And Publish Release
4+
5+
on:
6+
workflow_dispatch:
7+
release:
8+
types:
9+
- published
10+
11+
permissions:
12+
contents: read
13+
14+
env:
15+
IMAGE: rancher/kube-api-auth
16+
17+
jobs:
18+
push:
19+
permissions:
20+
contents: read
21+
id-token: write # this is important, it's how we authenticate with Vault
22+
runs-on: ubuntu-latest
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
platform:
27+
- linux/amd64
28+
- linux/arm64
29+
steps:
30+
- name: Prepare Matrix Instance
31+
run: |
32+
platform=${{ matrix.platform }}
33+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
34+
35+
- name: Retrieve Docker Hub Credentials From Vault
36+
uses: rancher-eio/read-vault-secrets@main
37+
with:
38+
secrets: |
39+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
40+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
41+
42+
- name: Login to Docker Hub
43+
uses: docker/login-action@v3
44+
with:
45+
username: ${{ env.DOCKERHUB_USERNAME }}
46+
password: ${{ env.DOCKERHUB_PASSWORD }}
47+
48+
- name: Get Sources
49+
uses: actions/checkout@v4
50+
51+
- name: Docker Meta Data Setup
52+
id: meta
53+
uses: docker/metadata-action@v5
54+
with:
55+
images: ${{ env.IMAGE }}
56+
57+
- name: Set up QEMU
58+
uses: docker/setup-qemu-action@v3
59+
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Set up Go
64+
uses: actions/setup-go@v5
65+
with:
66+
go-version: '1.22'
67+
cache: false
68+
69+
- name: Build and stage
70+
run: |
71+
case "${{ matrix.platform }}" in
72+
*/arm64) export ARCH=arm64 ; export GOARCH=arm64 ;;
73+
*) export ARCH=amd64 ; export GOARCH=amd64 ;;
74+
esac
75+
./scripts/build
76+
# Stage binary for packaging step
77+
cp -r ./bin/* ./package/
78+
79+
- name: Build image and push by digest
80+
id: build
81+
uses: docker/build-push-action@v5
82+
with:
83+
context: package
84+
file: package/Dockerfile
85+
platforms: ${{ matrix.platform }}
86+
labels: ${{ steps.meta.outputs.labels }}
87+
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
88+
89+
- name: Export digest
90+
run: |
91+
mkdir -p /tmp/digests
92+
digest="${{ steps.build.outputs.digest }}"
93+
touch "/tmp/digests/${digest#sha256:}"
94+
95+
- name: Upload digest
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: digests-${{ env.PLATFORM_PAIR }}
99+
path: /tmp/digests/*
100+
if-no-files-found: error
101+
retention-days: 1
102+
103+
merge:
104+
permissions:
105+
contents: read
106+
id-token: write # this is important, it's how we authenticate with Vault
107+
runs-on: ubuntu-latest
108+
needs:
109+
- push
110+
steps:
111+
- name: Retrieve Docker Hub Credentials From Vault
112+
uses: rancher-eio/read-vault-secrets@main
113+
with:
114+
secrets: |
115+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ;
116+
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD
117+
118+
- name: Login to Docker Hub
119+
uses: docker/login-action@v3
120+
with:
121+
username: ${{ env.DOCKERHUB_USERNAME }}
122+
password: ${{ env.DOCKERHUB_PASSWORD }}
123+
124+
- name: Download digests
125+
uses: actions/download-artifact@v4
126+
with:
127+
path: /tmp/digests
128+
pattern: digests-*
129+
merge-multiple: true
130+
131+
- name: Set up Docker Buildx
132+
uses: docker/setup-buildx-action@v3
133+
134+
- name: Docker meta
135+
id: meta
136+
uses: docker/metadata-action@v5
137+
with:
138+
images: ${{ env.IMAGE }}
139+
140+
- name: Create manifest list and push
141+
working-directory: /tmp/digests
142+
run: |
143+
docker buildx imagetools create \
144+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
145+
$(printf '${{ env.IMAGE }}@sha256:%s ' *)
146+
147+
- name: Inspect image
148+
run: |
149+
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }}

0 commit comments

Comments
 (0)