-
Notifications
You must be signed in to change notification settings - Fork 229
161 lines (140 loc) · 4.75 KB
/
passkey-bundler-docker.yml
File metadata and controls
161 lines (140 loc) · 4.75 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Passkey Bundler Docker
on:
push:
branches:
- main
tags:
- "passkey-bundler/v*"
workflow_dispatch:
permissions:
contents: read
packages: write
concurrency:
group: passkey-bundler-docker-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
bundler: ${{ steps.determine.outputs.bundler }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine whether to build
id: determine
run: |
set -euo pipefail
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
echo "bundler=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "${GITHUB_REF}" == refs/tags/passkey-bundler/v* ]]; then
echo "bundler=true" >> "$GITHUB_OUTPUT"
exit 0
fi
before="${{ github.event.before }}"
if [[ -z "${before}" || "${before}" == "0000000000000000000000000000000000000000" ]]; then
echo "bundler=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if git diff --name-only "${before}" "${GITHUB_SHA}" -- "passkey-bundler" ".github/workflows/passkey-bundler-docker.yml" | grep -q .; then
echo "bundler=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "bundler=false" >> "$GITHUB_OUTPUT"
build:
name: Build (${{ matrix.build.platform }})
needs: [changes]
if: |
github.event_name == 'workflow_dispatch' ||
startsWith(github.ref, 'refs/tags/passkey-bundler/v') ||
needs.changes.outputs.bundler == 'true'
strategy:
fail-fast: true
matrix:
build:
- platform: linux/amd64
runner: ubuntu-22.04
- platform: linux/arm64
runner: ubuntu-22.04-arm
runs-on: ${{ matrix.build.runner }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Prepare env vars
run: |
ARCH="$(echo "${{ matrix.build.platform }}" | cut -d '/' -f 2)"
echo "ARCH=$ARCH" >> "$GITHUB_ENV"
echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV"
OWNER="${{ github.repository_owner }}"
OWNER="${OWNER,,}"
echo "IMAGE=ghcr.io/${OWNER}/passkey-bundler" >> "$GITHUB_ENV"
if [[ "${GITHUB_REF}" == refs/tags/passkey-bundler/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/passkey-bundler/v}"
echo "TAG_PREFIX=$VERSION" >> "$GITHUB_ENV"
else
echo "TAG_PREFIX=main" >> "$GITHUB_ENV"
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (arch)
uses: docker/build-push-action@v6
with:
context: passkey-bundler
push: true
platforms: ${{ matrix.build.platform }}
tags: ${{ env.IMAGE }}:${{ env.TAG_PREFIX }}-${{ env.ARCH }}
merge:
name: Create multi-arch image
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Prepare env vars
run: |
echo "SHORT_SHA=${GITHUB_SHA::7}" >> "$GITHUB_ENV"
OWNER="${{ github.repository_owner }}"
OWNER="${OWNER,,}"
echo "IMAGE=ghcr.io/${OWNER}/passkey-bundler" >> "$GITHUB_ENV"
if [[ "${GITHUB_REF}" == refs/tags/passkey-bundler/v* ]]; then
VERSION="${GITHUB_REF#refs/tags/passkey-bundler/v}"
echo "TAG_PREFIX=$VERSION" >> "$GITHUB_ENV"
echo "IS_RELEASE=true" >> "$GITHUB_ENV"
else
echo "TAG_PREFIX=main" >> "$GITHUB_ENV"
echo "IS_RELEASE=false" >> "$GITHUB_ENV"
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest list
run: |
set -euo pipefail
if [[ "${IS_RELEASE}" == "true" ]]; then
docker buildx imagetools create \
--tag "${IMAGE}:${TAG_PREFIX}" \
--tag "${IMAGE}:latest" \
"${IMAGE}:${TAG_PREFIX}-amd64" \
"${IMAGE}:${TAG_PREFIX}-arm64"
else
docker buildx imagetools create \
--tag "${IMAGE}:main" \
--tag "${IMAGE}:sha-${SHORT_SHA}" \
"${IMAGE}:main-amd64" \
"${IMAGE}:main-arm64"
fi