-
Notifications
You must be signed in to change notification settings - Fork 58
149 lines (129 loc) · 4.21 KB
/
publish-docker-image.yml
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
name: Publish Docker Image
on:
workflow_dispatch:
push:
branches:
- "main"
release:
types: [published]
jobs:
build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- uses: pnpm/[email protected]
with:
version: latest
- uses: actions/setup-node@v4
with:
cache: pnpm
node-version: latest
- name: Build
run: |
pnpm install
pnpm build
- name: Upload artifact - web
uses: actions/upload-artifact@v4
with:
name: web
path: dist
publish-docker-image:
runs-on: ubuntu-latest
needs:
- build-web
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Download artifact - web
uses: actions/download-artifact@v4
with:
name: web
path: dist/
- name: Prepare Tag
# Borrowed from daeuniverse/dae
id: prep
env:
REF: ${{ github.ref }}
run: |
DIR="$(pwd)/dist/"
if [ -d "$DIR" ]; then
### Take action if $DIR exists ###
echo "Installing config files in ${DIR}..."
else
### Control will jump here if $DIR does NOT exists ###
echo "Error: ${DIR} not found. Can not continue."
exit 1
fi
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
tag=${tag:1}
else
tag=$(git log -1 --format="%cd" --date=short | sed s/-//g)
fi
echo "IMAGE=daeuniverse/daed" >> $GITHUB_OUTPUT
echo "TAG=$tag" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to ghrc.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ github.repository_owner }}
password: ${{ secrets.QUAY_PASS }}
- name: Build image
if: github.event_name == 'release'
uses: docker/build-push-action@v5
with:
context: .
build-args: DAED_VERSION=${{ steps.prep.outputs.TAG }}
builder: ${{ steps.buildx.outputs.name }}
file: publish.Dockerfile
target: prod
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ github.repository }}:latest
${{ github.repository }}:${{ steps.prep.outputs.TAG }}
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ steps.prep.outputs.TAG }}
quay.io/${{ github.repository }}:latest
quay.io/${{ github.repository }}:${{ steps.prep.outputs.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Build
if: github.event_name != 'release'
uses: docker/build-push-action@v5
with:
context: .
build-args: DAED_VERSION=${{ steps.prep.outputs.TAG }}
builder: ${{ steps.buildx.outputs.name }}
file: publish.Dockerfile
target: prod
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
${{ github.repository }}:test
${{ github.repository }}:${{ steps.prep.outputs.TAG }}-test
ghcr.io/${{ github.repository }}:test
ghcr.io/${{ github.repository }}:${{ steps.prep.outputs.TAG }}-test
quay.io/${{ github.repository }}:test
quay.io/${{ github.repository }}:${{ steps.prep.outputs.TAG }}-test
cache-from: type=gha
cache-to: type=gha,mode=max