mirror of
https://github.com/tcgdex/cards-database.git
synced 2025-04-25 12:22:14 +00:00
Update build.yml
This commit is contained in:
parent
930b18e80a
commit
0ede67bd7d
235
.github/workflows/build.yml
vendored
235
.github/workflows/build.yml
vendored
@ -1,125 +1,148 @@
|
|||||||
name: Build Docker image
|
name: ci
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- '*'
|
env:
|
||||||
tags:
|
REGISTRY_IMAGE: |
|
||||||
- v*
|
ghcr.io/tcgdex/server
|
||||||
pull_request:
|
tcgdex/server
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_amd:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
strategy:
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
fail-fast: false
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
matrix:
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
# - linux/arm/v6
|
||||||
|
# - linux/arm/v7
|
||||||
|
- linux/arm64
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Prepare
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
with:
|
platform=${{ matrix.platform }}
|
||||||
fetch-depth: 0
|
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
ghcr.io/tcgdex/server
|
tags: |
|
||||||
tcgdex/server
|
type=edge
|
||||||
tags: |
|
type=ref,event=pr
|
||||||
type=edge
|
type=ref,event=branch,prefix=branch-
|
||||||
type=ref,event=pr
|
type=semver,pattern={{version}}
|
||||||
type=ref,event=branch,prefix=branch-
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{major}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern=latest
|
||||||
type=semver,pattern={{major}}
|
|
||||||
type=semver,pattern=latest
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USER }}
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
||||||
|
|
||||||
- name: Login to Github Packages
|
- name: Login to Github Packages
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.DOCKER_TOKEN }}
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up QEMU
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
if: ${{ matrix.platform != 'linux/amd64' }}
|
||||||
|
|
||||||
- name: Build and push AMD64 image
|
- name: Set up Docker Buildx
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64
|
|
||||||
push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
|
||||||
file: ./Dockerfile
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
|
||||||
build_arm:
|
- name: Build and push by digest
|
||||||
|
id: build
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
file: ./Dockerfile
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
outputs: |
|
||||||
|
${{ env.REGISTRY_IMAGES }} | while read image; do
|
||||||
|
echo "type=image,name=$image,push-by-digest=true,name-canonical=true,push=true";
|
||||||
|
done
|
||||||
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build_amd # Ensures ARM64 build waits for AMD64 to finish
|
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
||||||
# if: github.event_name != 'pull_request' # Optional: Skip ARM64 build on PRs for faster feedback
|
needs:
|
||||||
|
- build
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Download digests
|
||||||
uses: actions/checkout@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
path: /tmp/digests
|
||||||
|
pattern: digests-*
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Set up Docker Buildx
|
||||||
id: meta
|
uses: docker/setup-buildx-action@v3
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
ghcr.io/tcgdex/server
|
|
||||||
tcgdex/server
|
|
||||||
tags: ${{ needs.build_amd.outputs.tags }}
|
|
||||||
labels: ${{ needs.build_amd.outputs.labels }}
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Docker meta
|
||||||
uses: docker/login-action@v3
|
id: meta
|
||||||
with:
|
uses: docker/metadata-action@v5
|
||||||
username: ${{ secrets.DOCKERHUB_USER }}
|
with:
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
images: ${{ env.REGISTRY_IMAGE }}
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
tags: |
|
||||||
|
type=edge
|
||||||
|
type=ref,event=pr
|
||||||
|
type=ref,event=branch,prefix=branch-
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
type=semver,pattern=latest
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Login to Github Packages
|
- name: Login to Github Packages
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.DOCKER_TOKEN }}
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
|
||||||
|
|
||||||
- name: Set up QEMU for ARM emulation
|
- name: Create manifest list and push for each image
|
||||||
uses: docker/setup-qemu-action@v3
|
working-directory: /tmp/digests
|
||||||
|
run: |
|
||||||
|
echo "${{ env.REGISTRY_IMAGES }}" | while read image; do
|
||||||
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
|
$(printf "$image@sha256:%s " *);
|
||||||
|
done
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Inspect image
|
||||||
uses: docker/setup-buildx-action@v3
|
run: |
|
||||||
with:
|
echo "${{ env.REGISTRY_IMAGES }}" | while read image; do
|
||||||
install: true
|
docker buildx imagetools inspect $image:${{ steps.meta.outputs.version }};
|
||||||
|
done
|
||||||
- name: Build and push ARM64 image
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/arm64
|
|
||||||
push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
|
||||||
file: ./Dockerfile
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user