-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add beta-test workflow for Docker build and push
This commit adds a new workflow called "beta-test.yml" for Docker build and push by digest. The workflow is triggered on push to the "v3-beta" branch and can also be manually triggered. The workflow includes steps to clear digests, build the image for multiple platforms, get metadata from the Docker image, set up QEMU and Docker Buildx, login to GHCR, build and push the image, export the digest, and upload the digest as an artifact. There is also a merge step that downloads the digests, sets up Docker Buildx, gets metadata from the Docker image, logs in to GHCR, creates a manifest list, and inspects the image.
- Loading branch information
1 parent
aef32ee
commit 17ba455
Showing
1 changed file
with
133 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
name: Docker Build and Push by Digest | ||
|
||
on: | ||
push: | ||
branches: | ||
- "v3-beta" | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
packages: write | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: wizarrrr/wizarr | ||
IMAGE_TAG: v3-beta | ||
|
||
jobs: | ||
clear: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Clear the digests from the artifacts | ||
- name: Clear digests | ||
uses: geekyeggo/delete-artifact@v2 | ||
with: | ||
name: digests | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- linux/amd64 | ||
- linux/arm/v6 | ||
- linux/arm/v7 | ||
- linux/arm64 | ||
|
||
steps: | ||
# Checkout the repo | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
# Get the Metadata from the Docker Image | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | ||
|
||
# Set up QEMU | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
# Set up Docker Buildx | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# Login to GHCR | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Build and push the image | ||
- name: Build and push by digest | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: ${{ matrix.platform }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true | ||
|
||
# Export the digest for later use | ||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
# Upload the digest as an artifact | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
merge: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
steps: | ||
# Download the digests from the artifacts | ||
- name: Download digests | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: digests | ||
path: /tmp/digests | ||
|
||
# Set up Docker Buildx | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
# Get the Metadata from the Docker Image | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | ||
|
||
# Login to GHCR | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Create manifest list and push | ||
- 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.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}@sha256:%s ' *) | ||
# Inspect image | ||
- name: Inspect image | ||
run: | | ||
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} |