1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-06-07 21:59:54 +00:00

Update build.yml

This commit is contained in:
Florian Bouillon 2024-08-30 15:29:18 +02:00
parent 2efc86f3bb
commit 1c0b3c368d

View File

@ -1,4 +1,4 @@
name: ci name: Build Docker image
on: on:
push: push:
@ -12,7 +12,6 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: false
matrix: matrix:
platform: platform:
- linux/amd64 - linux/amd64
@ -27,11 +26,6 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Prepare
run: |
platform=${{ matrix.platform }}
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
@ -78,79 +72,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
outputs: |
type=image,name=ghcr.io/tcgdex/server,push-by-digest=true,name-canonical=true
type=image,name=tcgdex/server,push-by-digest=true,name-canonical=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
deploy:
runs-on: ubuntu-latest
name: Deploying TCGdex
if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
needs:
- build
steps:
- 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.REGISTRY_IMAGE }}
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
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Create manifest list and push for each image
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: Inspect image
run: |
echo "${{ env.REGISTRY_IMAGES }}" | while read image; do
docker buildx imagetools inspect $image:${{ steps.meta.outputs.version }};
done