feat(ci): build for ghcr #17
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 CI | |
on: [push, pull_request] | |
jobs: | |
build-export: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64 | |
push: false | |
tags: localhost/darkness4/katago:test | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Login to GitHub Container Registry | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
if: startsWith(github.ref, 'refs/tags/') | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: | | |
latest=true | |
images: | | |
docker.io/darkness4/katago | |
tags: | | |
type=ref,event=tag | |
type=sha | |
- name: Tag and export | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
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 |