動かざることバグの如し

近づきたいよ 君の理想に

GitHub ActionでGithub Container Registryにpushする

環境

  • 2020-12-31現在

成果物

thr3a/imagemagick-docker

docker pull ghcr.io/thr3a/imagick

YAML

.github/workflows/action.ymlを用意

name: Build and Publish Docker

on:
  push:
    branches:
      - master

jobs:
  build_and_push:
    runs-on: ubuntu-20.04
    env:
      IMAGE_NAME: imagick
    steps:
      - name: checkout
        uses: actions/checkout@v2

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

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          push: true
          tags: |
            ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
            ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:1.0.0

参考リンク