Skip to content

Commit

Permalink
Update build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviortheking authored Aug 30, 2024
1 parent 3a728a1 commit 1b95557
Showing 1 changed file with 2 additions and 81 deletions.
83 changes: 2 additions & 81 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: Build Docker image

on:
push:
Expand All @@ -12,7 +12,6 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
Expand All @@ -27,11 +26,6 @@ jobs:
with:
fetch-depth: 0

- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -78,79 +72,6 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
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

0 comments on commit 1b95557

Please sign in to comment.