Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Build And Publish Release | |
on: | |
release: | |
types: | |
- published | |
permissions: | |
contents: read | |
env: | |
IMAGE: rancher/kube-api-auth | |
jobs: | |
push: | |
permissions: | |
contents: read | |
id-token: write # this is important, it's how we authenticate with Vault | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- linux | |
arch: | |
- amd64 | |
- arm64 | |
steps: | |
- name: Prepare Matrix Instance | |
run: | | |
echo "PLATFORM_PAIR=${{ matrix.os }}-${{ matrix.arch }}" | |
echo "PLATFORM_PAIR=${{ matrix.os }}-${{ matrix.arch }}" >> $GITHUB_ENV | |
echo "GOOS=${{ matrix.os }}" | |
echo "GOOS=${{ matrix.os }}" >> $GITHUB_ENV | |
echo "GOARCH=${{ matrix.arch }}" | |
echo "GOARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
echo "ARCH=${{ matrix.arch }}" | |
echo "ARCH=${{ matrix.arch }}" >> $GITHUB_ENV | |
- name: Retrieve Docker Hub Credentials From Vault | |
uses: rancher-eio/read-vault-secrets@main | |
with: | |
secrets: | | |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKERHUB_USERNAME ; | |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKERHUB_PASSWORD | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ env.DOCKERHUB_PASSWORD }} | |
- name: Get Sources | |
uses: actions/checkout@v4 | |
- name: Docker Meta Data Setup | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
cache: false | |
- name: Build and stage | |
run: | | |
./scripts/build | |
# Stage binary for packaging step | |
cp -r ./bin/* ./package/ | |
- name: Build image and push by digest | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: package | |
file: package/Dockerfile | |
platforms: ${{ matrix.os }}/${{ matrix.arch }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
permissions: | |
contents: read | |
id-token: write # this is important, it's how we authenticate with Vault | |
runs-on: ubuntu-latest | |
needs: | |
- push | |
steps: | |
- name: Retrieve Docker Hub Credentials From Vault | |
uses: rancher-eio/read-vault-secrets@main | |
with: | |
secrets: | | |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKERHUB_USERNAME ; | |
secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKERHUB_PASSWORD | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ env.DOCKERHUB_PASSWORD }} | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create \ | |
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }} |