Skip to content

Commit

Permalink
feat(ci): build for ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkness4 committed Apr 29, 2024
1 parent c0d18d8 commit 925252b
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
Expand All @@ -25,7 +25,7 @@ jobs:

- name: Login to GitHub Container Registry
if: startsWith(github.ref, 'refs/tags/')
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Docker meta
if: startsWith(github.ref, 'refs/tags/')
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
flavor: |
latest=true
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Tag and export
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
Expand All @@ -56,3 +56,37 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Login to GHCR
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
if: startsWith(github.ref, 'refs/tags/')
id: meta-ghcr
uses: docker/metadata-action@v5
with:
flavor: |
latest=true
images: |
ghcr.io/darkness4/katago
tags: |
type=ref,event=tag
type=sha
- name: Build and export
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-ghcr.outputs.tags }}
labels: ${{ steps.meta-ghcr.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 925252b

Please sign in to comment.