-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (50 loc) · 1.5 KB
/
wf-docker-build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Build Docker Images
on:
workflow_call:
inputs:
push-ghcr:
type: boolean
default: false
save-cache:
type: boolean
default: false
jobs:
build_and_push:
name: Build and Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/setup-qemu-action@v3
- if: inputs.push-ghcr
name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ inputs.push-ghcr && format('ghcr.io/{0}', github.repository) || '' }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=pr
type=sha
- name: Build and Push Artifacts
uses: docker/bake-action@v6
with:
source: .
push: ${{ inputs.push-ghcr }}
files: |
docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
# 基本的に main ブランチのキャッシュしか共有できないのでキャッシュの保存はオプトインにしておく
set: |
*.cache-from=type=gha
${{ inputs.save-cache && '*.cache-to=type=gha,mode=max' || '' }}