-
Notifications
You must be signed in to change notification settings - Fork 92
180 lines (156 loc) · 5 KB
/
nightly-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
name: CI/CD Build Image [Nightly]
on:
push:
branches:
- develop
workflow_dispatch: {}
permissions:
packages: write
contents: write
env:
GHCR_REGISTRY: ghcr.io
DH_REGISTRY: docker.io
IMAGE_NAME: wizarrrr/wizarr
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 repository
- 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
# Use Python and Poetry to install dependencies
- uses: actions/setup-python@v4
with:
python-version: "3.10"
# Install Poetry and configure it to not create a virtual environment
- name: Install Poetry
run: |
pip install poetry==1.6.1
poetry config virtualenvs.create false
# Install the dependencies for the repository
- 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 by digest
- 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 to a file
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
# Upload the digest to the artifacts
- 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 repository
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
# Check if the tag is a beta or latest release
- name: Get Release Branch
id: release-branch
run: |
if [[ ${{ github.ref }} == 'refs/heads/develop' ]]; then
echo "::set-output name=release_branch::nightly"
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 }}
# Create manifest list and push to Registry
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.DH_REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Create manifest list and push to Registry
- 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.DH_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.release-branch.outputs.release_branch }} \
$(printf '${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
# Inspect the image
- name: Inspect image
run: docker buildx imagetools inspect ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.release-branch.outputs.release_branch }}