Rewrite workflow #9
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: Docker Image CI | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
REGISTRY_IMAGE: ghcr.io/${{ github.repository }} | |
on: | |
push: | |
release: | |
types: | |
- created | |
#jobs: | |
# build-release: | |
# if: "!github.event.release.prerelease" | |
# runs-on: ubuntu-latest | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# platform: | |
# - linux/amd64 | |
# - linux/arm64 | |
# | |
# # See https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners | |
# steps: | |
# - uses: actions/checkout@v4 | |
# | |
# - name: Log in to registry | |
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
# | |
# - name: Get Previous tag | |
# id: previoustag | |
# uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
# with: | |
# fallback: v0.1 | |
# | |
# - name: Set up Docker Buildx | |
# id: buildx | |
# uses: docker/setup-buildx-action@v3 | |
# | |
# - name: Build and push | |
# id: docker_build | |
# uses: docker/build-push-action@v6 | |
# with: | |
# push: true | |
# context: . | |
# target: target | |
# file: ./Dockerfile | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
# platforms: ${{ matrix.platform }} | |
# build-args: VITE_BUILD_ID="Github Actions" | |
# tags: | |
# ${{ env.REGISTRY_IMAGE }}:latest, ${{ env.REGISTRY_IMAGE }}:${{ steps.previoustag.outputs.tag }} | |
jobs: | |
build-node: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push by digest | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
load: true | |
target: builder | |
file: ./Dockerfile | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: VITE_BUILD_ID="Github Actions" | |
platforms: linux/amd64 | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=docker,dest=/tmp/docker-builder.tar | |
- name: Share builder image | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-builder | |
path: /tmp/docker-builder.tar | |
if-no-files-found: error | |
retention-days: 1 | |
build: | |
runs-on: ubuntu-latest | |
needs: [build-node] | |
steps: | |
- name: Log in to registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Download builder image | |
uses: actions/download-artifact@v4 | |
with: | |
path: /tmp/docker-builder | |
merge-multiple: true | |
- name: Load image | |
run: | | |
docker load --input /tmp/docker-builder.tar | |
docker image ls -a | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
context: . | |
target: target | |
file: ./Dockerfile | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64,linux/arm64 | |
tags: | |
${{ env.REGISTRY_IMAGE }}:latest, ${{ env.REGISTRY_IMAGE }}:${{ steps.previoustag.outputs.tag }} |