Repository navigation
211 lines (187 loc) · 6.95 KB
/
Copy pathrelease.yml
File metadata and controls
211 lines (187 loc) · 6.95 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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: Release
on:
workflow_run:
workflows: ["CI"]
types:
- completed
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
IMAGE_DESCRIPTION: >
CinePro Core is the central scraping and streaming engine of the CinePro
ecosystem. It exposes an OMSS-compliant HTTP API for resolving movie and TV
show streams from multiple providers.
concurrency:
group: docker-build-${{ github.event.workflow_run.head_branch || github.ref }}
cancel-in-progress: true
jobs:
prepare:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main')
runs-on: ubuntu-latest
outputs:
app_version: ${{ steps.meta.outputs.app_version }}
arch_tag_amd64: ${{ steps.meta.outputs.arch_tag_amd64 }}
arch_tag_arm64: ${{ steps.meta.outputs.arch_tag_arm64 }}
created: ${{ steps.meta.outputs.created }}
steps:
- id: meta
run: |
SHA="${{ github.event.workflow_run.head_sha || github.sha }}"
SHORT_SHA="${SHA::7}"
APP_VERSION="main-${SHORT_SHA}"
CREATED="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
{
echo "app_version=${APP_VERSION}"
echo "arch_tag_amd64=${APP_VERSION}-amd64"
echo "arch_tag_arm64=${APP_VERSION}-arm64"
echo "created=${CREATED}"
} >> "$GITHUB_OUTPUT"
build-amd64:
runs-on: ubuntu-latest
needs: [prepare]
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build-push.outputs.digest }}
steps:
- uses: actions/checkout@v4
- name: Set lowercase image name
run: echo "IMAGE_NAME_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build test image
run: docker buildx build --load -t cinepro-core:test .
- name: Test Docker image
run: |
docker run -d --name cinepro-core-test \
-p 3000:3000 \
-e NODE_ENV=production \
-e HOST=0.0.0.0 \
-e PORT=3000 \
-e CACHE_TYPE=memory \
-e TMDB_API_KEY=dummy-ci-key \
cinepro-core:test
sleep 10
docker logs cinepro-core-test
curl -sf http://localhost:3000 || true
- name: Cleanup test container
if: always()
run: docker rm -f cinepro-core-test || true
- name: Build and push Docker image (amd64)
id: build-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
provenance: false
sbom: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ needs.prepare.outputs.arch_tag_amd64 }}
cache-from: type=gha,scope=amd64
cache-to: type=gha,mode=max,scope=amd64
build-args: |
VERSION=${{ needs.prepare.outputs.app_version }}
REVISION=${{ github.event.workflow_run.head_sha }}
CREATED=${{ needs.prepare.outputs.created }}
DESCRIPTION=${{ env.IMAGE_DESCRIPTION }}
SOURCE=${{ github.server_url }}/${{ github.repository }}
build-arm64:
runs-on: ubuntu-24.04-arm
needs: [prepare]
permissions:
contents: read
packages: write
outputs:
digest: ${{ steps.build-push.outputs.digest }}
steps:
- uses: actions/checkout@v4
- name: Set lowercase image name
run: echo "IMAGE_NAME_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image (arm64)
id: build-push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
provenance: false
sbom: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}:${{ needs.prepare.outputs.arch_tag_arm64 }}
cache-from: type=gha,scope=arm64
cache-to: type=gha,mode=max,scope=arm64
build-args: |
VERSION=${{ needs.prepare.outputs.app_version }}
REVISION=${{ github.event.workflow_run.head_sha }}
CREATED=${{ needs.prepare.outputs.created }}
DESCRIPTION=${{ env.IMAGE_DESCRIPTION }}
SOURCE=${{ github.server_url }}/${{ github.repository }}
manifest:
runs-on: ubuntu-latest
needs: [prepare, build-amd64, build-arm64]
if: >-
github.event_name != 'pull_request' &&
needs.prepare.result == 'success' &&
needs.build-amd64.result == 'success' &&
needs.build-arm64.result == 'success'
permissions:
contents: write
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set lowercase image name
run: echo "IMAGE_NAME_LC=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/setup-buildx-action@v3
- name: Create and push multi-arch manifests with description
run: |
IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LC }}"
AMD64_IMAGE="$IMAGE:${{ needs.prepare.outputs.arch_tag_amd64 }}"
ARM64_IMAGE="$IMAGE:${{ needs.prepare.outputs.arch_tag_arm64 }}"
DESC="${{ env.IMAGE_DESCRIPTION }}"
# Versioned tag
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.description=${DESC}" \
-t "$IMAGE:${{ needs.prepare.outputs.app_version }}" \
"$AMD64_IMAGE" "$ARM64_IMAGE"
# Moving tags
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.description=${DESC}" \
-t "$IMAGE:main" \
"$AMD64_IMAGE" "$ARM64_IMAGE"
docker buildx imagetools create \
--annotation "index:org.opencontainers.image.description=${DESC}" \
-t "$IMAGE:latest" \
"$AMD64_IMAGE" "$ARM64_IMAGE"
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ needs.prepare.outputs.app_version }}"
gh release view "$TAG" >/dev/null 2>&1 || \
gh release create "$TAG" \
--title "$TAG" \
--generate-notes \
--latest