-
Notifications
You must be signed in to change notification settings - Fork 4
161 lines (146 loc) · 5.21 KB
/
build-images.yml
File metadata and controls
161 lines (146 loc) · 5.21 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: Build and Push Images
on:
push:
branches:
- '**'
tags:
- '**'
paths:
- 'images/**'
- 'mie-opensource-landing/**'
- 'Makefile'
pull_request:
types: [opened, synchronize, reopened, closed]
paths:
- 'images/**'
- 'mie-opensource-landing/**'
- 'Makefile'
schedule:
# Run weekly on Sunday at 11:00 PM UTC (Sunday-Monday night depending on timezone)
- cron: '0 23 * * 0'
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
if: github.event_name != 'pull_request' || github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Meta (Base)
id: meta-base
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/base
bake-target: base
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Docker Meta (NodeJS)
id: meta-nodejs
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/nodejs
bake-target: nodejs
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Docker Meta (Docs)
id: meta-docs
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/docs
bake-target: docs
tags: |
type=sha
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Docker Meta (Agent)
id: meta-agent
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/agent
bake-target: agent
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Docker Meta (Manager)
id: meta-manager
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/manager
bake-target: manager
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
- name: Build and push
uses: docker/bake-action@v5
with:
workdir: ./images
push: true
files: |
./docker-bake.hcl
${{ steps.meta-base.outputs.bake-file }}
${{ steps.meta-nodejs.outputs.bake-file }}
${{ steps.meta-docs.outputs.bake-file }}
${{ steps.meta-agent.outputs.bake-file }}
${{ steps.meta-manager.outputs.bake-file }}
set: |
base.cache-from=type=gha,scope=base-${{ github.ref_name }}
base.cache-to=type=gha,mode=max,scope=base-${{ github.ref_name }}
nodejs.cache-from=type=gha,scope=nodejs-${{ github.ref_name }}
nodejs.cache-to=type=gha,mode=max,scope=nodejs-${{ github.ref_name }}
docs.cache-from=type=gha,scope=docs-${{ github.ref_name }}
docs.cache-to=type=gha,mode=max,scope=docs-${{ github.ref_name }}
agent.cache-from=type=gha,scope=agent-${{ github.ref_name }}
agent.cache-to=type=gha,mode=max,scope=agent-${{ github.ref_name }}
manager.cache-from=type=gha,scope=manager-${{ github.ref_name }}
manager.cache-to=type=gha,mode=max,scope=manager-${{ github.ref_name }}
deploy-preview:
if: github.event.action != 'closed'
needs: build-and-push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mieweb/launchpad@cmyers_issue5
with:
api_key: ${{ secrets.API_KEY }}
api_url: ${{ secrets.API_URL }}
template_name: ${{ env.REGISTRY }}/${{ github.repository }}/docs:${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}
cleanup-preview:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove preview container
uses: mieweb/launchpad@cmyers_issue5
with:
api_key: ${{ secrets.LAUNCHPAD_API_KEY }}
api_url: ${{ secrets.LAUNCHPAD_API_URL }}