-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (136 loc) · 4.73 KB
/
docker.yaml
File metadata and controls
162 lines (136 loc) · 4.73 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
162
name: Publish Docker Images
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: {}
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-docker
cancel-in-progress: true
jobs:
discover:
name: Discover functions
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.find.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Find functions from handler.json
id: find
run: |
entries=$(
for f in functions/*/handler.json; do
[ -f "$f" ] || continue
name=$(jq -r .name "$f")
dir=$(basename "$(dirname "$f")")
echo "{\"name\":\"$name\",\"dir\":\"$dir\"}"
done | jq -s -c '.'
)
echo "matrix={\"include\":$entries}" >> "$GITHUB_OUTPUT"
echo "Discovered functions: $entries"
build:
name: Build ${{ matrix.name }}-fn
needs: discover
runs-on: ubuntu-latest
if: ${{ needs.discover.outputs.matrix != '{"include":[]}' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.discover.outputs.matrix) }}
env:
REGISTRY: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@v6
# Pinned to v4: setup-node@v5 auto-detects pnpm via the
# packageManager field in package.json and tries to cache the
# store, which fails here because this workflow doesn't run
# `pnpm install` on the runner — the store path doesn't exist
# and v5 promotes the "missing path" warning to an error.
# Sticking to v4 until v5's auto-cache can be opted out cleanly.
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Generate Dockerfile
run: |
node --experimental-strip-types scripts/generate.ts --only=${{ matrix.dir }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.name }}-fn
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=sha,format=short,prefix=
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: generated/${{ matrix.dir }}/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}
build-job-service:
name: Build knative-job-service
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Generate workspace packages
run: |
node --experimental-strip-types scripts/generate.ts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/knative-job-service
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=sha,format=short,prefix=
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: job/service/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha,scope=knative-job-service
cache-to: type=gha,mode=max,scope=knative-job-service