This repository was archived by the owner on Jul 15, 2024. It is now read-only.
generated from KagChi/typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 3
86 lines (77 loc) · 2.81 KB
/
docker.yml
File metadata and controls
86 lines (77 loc) · 2.81 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Build & Push Docker Image to container image registry
on:
workflow_call:
inputs:
ADD_FLAVOR:
description: "Whether to add flavor (only -dev atm) to the image tag"
type: boolean
required: false
default: true
NO_CACHE:
description: "Whether to use build cache"
type: boolean
required: false
default: false
SCOPE:
description: "Scope of the image (e.g. 'bot')"
type: string
required: true
VERSION:
description: "Version of the image (e.g. 'v1.0.0')"
type: string
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
scope: ${{ fromJson(inputs.SCOPE) }}
steps:
- name: Check Out Repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 2
#- name: Set up QEMU (We don't need QEMU, because we don't build images for platforms other than linux/amd64, which is our current native arch in our infra
# uses: docker/setup-qemu-action@v1.2.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Login to GitHub Container Registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract flavor
id: flavor
if: ${{ inputs.ADD_FLAVOR == true }}
run: if [ "${{ github.event_name }}" = "release" ]; then echo ::set-output name=name::; else echo ::set-output name=name::-dev; fi
- name: Generate Docker image metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
id: img_meta
with:
flavor: |
latest=auto
suffix=${{ steps.flavor.outputs.name }}
images: ghcr.io/nezuchan/${{ matrix.scope }}
tags: |
${{ inputs.VERSION }}
latest
- name: Build and push
id: docker_build
uses: docker/build-push-action@31159d49c0d4756269a0940a750801a1ea5d7003 # v6.1.0
with:
context: ./
tags: ${{ steps.img_meta.outputs.tags }}
labels: ${{ steps.img_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
"SCOPE=@nezuchan/${{ matrix.scope }}"
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max
no-cache: ${{ inputs.NO_CACHE == true }}