-
Notifications
You must be signed in to change notification settings - Fork 92
192 lines (167 loc) · 6.34 KB
/
master-beta-ci.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: CI/CD Build Image [Master/Beta]
on:
push:
tags:
- "v*.*.*"
- "v*.*.*-beta.*"
permissions:
packages: write
contents: write
env:
GHCR_REGISTRY: ghcr.io
DH_REGISTRY: docker.io
IMAGE_NAME: wizarrrr/wizarr
# IMAGE_TAG: beta
jobs:
before_build:
name: Prepare for Build
runs-on: ubuntu-latest
steps:
# Clear the digests from the artifacts
- name: Clear digests
uses: geekyeggo/delete-artifact@v2
with:
name: |
digests_dh
digests_ghcr
build:
name: Build Digest for Registry
runs-on: ubuntu-latest
needs:
- before_build
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
# Checkout the repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
# Use NPM and Node.js to install dependencies
- name: Use Node.js 18.18.2
uses: actions/setup-node@v4
with:
node-version: 18.18.2
# Set up Python and install Poetry
- uses: actions/setup-python@v4
with:
python-version: "3.10"
# Install Poetry
- name: Install Poetry
run: |
pip install poetry==1.6.1
poetry config virtualenvs.create false
# Install dependencies
- name: Install dependencies
run: npm install
# Build the Repository
- name: Build the Repository
run: |
npx nx build wizarr-backend
npx nx build wizarr-frontend
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login to GHCR
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push the image
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./dockerfiles/wizarr-ci/Dockerfile
push: true
platforms: ${{ matrix.platform }}
provenance: false
outputs: type=image,name=${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true
# Export the digest for later use
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
# Upload the digest as an artifact
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests_ghcr
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
name: Merge Digest to Registry
runs-on: ubuntu-latest
needs:
- build
steps:
# Checkout the repo
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
# Check if the tag is a beta tag
- name: Get Release Branch
id: release-branch
run: |
if [[ ${{ github.ref }} == 'refs/tags/v'*.*.*-beta.* ]]; then
echo "::set-output name=release_branch::beta"
elif [[ ${{ github.ref }} == 'refs/tags/v'*.*.* ]]; then
echo "::set-output name=release_branch::latest"
else
echo "Unknown tag, not setting environment variable."
exit 1
fi
# Download the digests from the artifacts
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests_ghcr
path: /tmp/digests
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login to GHCR
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Login to Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.DH_REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Get the tag name
- name: Get tag name
id: tag
uses: dawidd6/action-get-tag@v1
with:
strip_v: true
# Create manifest list and push
- name: Create manifest list and push to Registry
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
--tag ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.release-branch.outputs.release_branch }} \
--tag ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} \
--tag ${{ env.DH_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.release-branch.outputs.release_branch }} \
--tag ${{ env.DH_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} \
$(printf '${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
# Inspect image
- name: Inspect image
run: docker buildx imagetools inspect ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.release-branch.outputs.release_branch }}