Skip to content

📝 README にドキュメント自動生成/NeoShowcaseブランチを加筆 #4

📝 README にドキュメント自動生成/NeoShowcaseブランチを加筆

📝 README にドキュメント自動生成/NeoShowcaseブランチを加筆 #4

Workflow file for this run

name: Build Docker Image
on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
CAN_PUSH: ${{ github.event_name != 'pull_request' && github.actor == github.repository_owner }}
steps:
- uses: actions/checkout@v5
- name: Generate Image Tags
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
- name: Login to GitHub Container Registry
if: env.CAN_PUSH
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ env.CAN_PUSH }}
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# deploy branch にビルド済みの Docker image を参照する Dockerfile を作成するJob
# deploy という名前の orphan branch が事前に作られている必要がある
#
# ```sh
# git switch --orphan deploy
# git rm -rf .
# git push HEAD:deploy
# ```
#
# deploy:
# name: Deploy
# runs-on: ubuntu-latest
# needs: build
# if: github.event_name != 'pull_request'
# permissions:
# contents: write
# steps:
# - uses: actions/checkout@v5
# with:
# ref: deploy
# - name: Create Dockerfile for deploy
# run: printf "%s\n" "$DOCKERFILE" > Dockerfile
# env:
# DOCKERFILE: |
# FROM ghcr.io/${{ github.repository }}:${{ github.sha }}
# # 必要に応じて設定を追加する
# - name: Push empty commit
# run: |
# git config user.name "GitHub Actions"
# git config user.email "actions@github.com"
# git add Dockerfile
# git commit -m "Trigger deploy: ${{ github.ref }}"
# git push origin HEAD:deploy
# env:
# GITHUB_TOKEN: ${{ github.token }}
#