Skip to content

Commit 16cebc6

Browse files
committed
chore: docker build
1 parent 41f3fb0 commit 16cebc6

File tree

2 files changed

+29
-228
lines changed

2 files changed

+29
-228
lines changed

.github/workflows/docker.yml

+28-227
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Publish Docker Image
2-
on:
2+
on:
33
push:
4-
branches: [ master ]
4+
branches: [master]
55

6-
concurrency:
6+
concurrency:
77
group: ${{ github.ref }}-${{ github.workflow }}
88
cancel-in-progress: true
99

@@ -20,11 +20,12 @@ jobs:
2020
- name: Set up Docker Buildx
2121
uses: docker/setup-buildx-action@v2
2222

23-
- name: Docker login
24-
uses: docker/login-action@v2
23+
- name: login to ghcr.io
24+
uses: docker/login-action@v3
2525
with:
26-
username: ${{ secrets.DOCKER_USERNAME }}
27-
password: ${{ secrets.DOCKER_PASSWORD }}
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
2829

2930
- name: Get commit SHA
3031
id: vars
@@ -37,38 +38,15 @@ jobs:
3738
with:
3839
platforms: linux/amd64
3940
context: scripts/
40-
tags: tindy2013/subconverter:latest
41+
tags: ghcr.io/metacubex/subconverter:latest
4142
build-args: |
4243
SHA=${{ steps.vars.outputs.sha_short }}
4344
outputs: type=image,push=true
4445

45-
- name: Replace tag without `v`
46-
if: startsWith(github.ref, 'refs/tags/')
47-
uses: actions/github-script@v6
48-
id: version
49-
with:
50-
script: |
51-
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
52-
result-encoding: string
53-
54-
- name: Build release and export
55-
id: build_rel
56-
if: startsWith(github.ref, 'refs/tags/')
57-
uses: docker/build-push-action@v3
58-
with:
59-
platforms: linux/amd64
60-
context: scripts/
61-
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
62-
outputs: type=image,push=true
63-
6446
- name: Save digest
6547
if: github.ref == 'refs/heads/master'
6648
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
6749

68-
- name: Save release digest
69-
if: startsWith(github.ref, 'refs/tags/')
70-
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
71-
7250
- name: Upload artifact
7351
uses: actions/upload-artifact@v3
7452
with:
@@ -87,11 +65,12 @@ jobs:
8765
- name: Set up Docker Buildx
8866
uses: docker/setup-buildx-action@v2
8967

90-
- name: Docker login
91-
uses: docker/login-action@v2
68+
- name: login to ghcr.io
69+
uses: docker/login-action@v3
9270
with:
93-
username: ${{ secrets.DOCKER_USERNAME }}
94-
password: ${{ secrets.DOCKER_PASSWORD }}
71+
registry: ghcr.io
72+
username: ${{ github.actor }}
73+
password: ${{ secrets.GITHUB_TOKEN }}
9574

9675
- name: Get commit SHA
9776
id: vars
@@ -104,120 +83,24 @@ jobs:
10483
with:
10584
platforms: linux/386
10685
context: scripts/
107-
tags: tindy2013/subconverter:latest
86+
tags: ghcr.io/metacubex/subconverter:latest
10887
build-args: |
10988
SHA=${{ steps.vars.outputs.sha_short }}
11089
outputs: type=image,push=true
11190

112-
- name: Replace tag without `v`
113-
if: startsWith(github.ref, 'refs/tags/')
114-
uses: actions/github-script@v6
115-
id: version
116-
with:
117-
script: |
118-
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
119-
result-encoding: string
120-
121-
- name: Build release and export
122-
id: build_rel
123-
if: startsWith(github.ref, 'refs/tags/')
124-
uses: docker/build-push-action@v3
125-
with:
126-
platforms: linux/386
127-
context: scripts/
128-
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
129-
outputs: type=image,push=true
130-
13191
- name: Save digest
13292
if: github.ref == 'refs/heads/master'
13393
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
13494

135-
- name: Save release digest
136-
if: startsWith(github.ref, 'refs/tags/')
137-
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
138-
13995
- name: Upload artifact
14096
uses: actions/upload-artifact@v3
14197
with:
14298
name: digest_386
14399
path: /tmp/digest.txt
144100

145-
armv7_build:
146-
name: Build ARMv7 Image
147-
runs-on: [self-hosted, linux, ARM64]
148-
steps:
149-
- name: Checkout base
150-
uses: actions/checkout@v3
151-
with:
152-
fetch-depth: 0
153-
154-
- name: Set up QEMU
155-
uses: docker/setup-qemu-action@v2
156-
157-
- name: Set up Docker Buildx
158-
uses: docker/setup-buildx-action@v2
159-
160-
- name: Docker login
161-
uses: docker/login-action@v2
162-
with:
163-
username: ${{ secrets.DOCKER_USERNAME }}
164-
password: ${{ secrets.DOCKER_PASSWORD }}
165-
166-
- name: Get commit SHA
167-
id: vars
168-
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
169-
170-
- name: Build and export
171-
id: build
172-
if: github.ref == 'refs/heads/master'
173-
uses: docker/build-push-action@v3
174-
with:
175-
platforms: linux/arm/v7
176-
context: scripts/
177-
tags: tindy2013/subconverter:latest
178-
build-args: |
179-
SHA=${{ steps.vars.outputs.sha_short }}
180-
THREADS=2
181-
outputs: type=image,push=true
182-
183-
- name: Replace tag without `v`
184-
if: startsWith(github.ref, 'refs/tags/')
185-
uses: actions/github-script@v6
186-
id: version
187-
with:
188-
script: |
189-
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
190-
result-encoding: string
191-
192-
- name: Build release and export
193-
id: build_rel
194-
if: startsWith(github.ref, 'refs/tags/')
195-
uses: docker/build-push-action@v3
196-
with:
197-
platforms: linux/arm/v7
198-
context: scripts/
199-
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
200-
build-args: |
201-
THREADS=2
202-
outputs: type=image,push=true
203-
204-
- name: Save digest
205-
if: github.ref == 'refs/heads/master'
206-
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
207-
208-
- name: Save release digest
209-
if: startsWith(github.ref, 'refs/tags/')
210-
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
211-
212-
- name: Upload artifact
213-
uses: actions/upload-artifact@v3
214-
with:
215-
name: digest_armv7
216-
path: /tmp/digest.txt
217-
218101
arm64_build:
219102
name: Build ARM64 Image
220-
runs-on: [self-hosted, linux, ARM64]
103+
runs-on: ubuntu-latest
221104
steps:
222105
- name: Checkout base
223106
uses: actions/checkout@v3
@@ -230,11 +113,12 @@ jobs:
230113
- name: Set up Docker Buildx
231114
uses: docker/setup-buildx-action@v2
232115

233-
- name: Docker login
234-
uses: docker/login-action@v2
116+
- name: login to ghcr.io
117+
uses: docker/login-action@v3
235118
with:
236-
username: ${{ secrets.DOCKER_USERNAME }}
237-
password: ${{ secrets.DOCKER_PASSWORD }}
119+
registry: ghcr.io
120+
username: ${{ github.actor }}
121+
password: ${{ secrets.GITHUB_TOKEN }}
238122

239123
- name: Get commit SHA
240124
id: vars
@@ -247,50 +131,24 @@ jobs:
247131
with:
248132
platforms: linux/arm64
249133
context: scripts/
250-
tags: tindy2013/subconverter:latest
134+
tags: ghcr.io/metacubex/subconverter:latest
251135
build-args: |
252136
SHA=${{ steps.vars.outputs.sha_short }}
253137
THREADS=2
254138
outputs: type=image,push=true
255139

256-
- name: Replace tag without `v`
257-
if: startsWith(github.ref, 'refs/tags/')
258-
uses: actions/github-script@v6
259-
id: version
260-
with:
261-
script: |
262-
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
263-
result-encoding: string
264-
265-
- name: Build release and export
266-
id: build_rel
267-
if: startsWith(github.ref, 'refs/tags/')
268-
uses: docker/build-push-action@v3
269-
with:
270-
platforms: linux/arm64
271-
context: scripts/
272-
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
273-
build-args: |
274-
THREADS=2
275-
outputs: type=image,push=true
276-
277140
- name: Save digest
278141
if: github.ref == 'refs/heads/master'
279142
run: echo ${{ steps.build.outputs.digest }} > /tmp/digest.txt
280143

281-
- name: Save release digest
282-
if: startsWith(github.ref, 'refs/tags/')
283-
run: echo ${{ steps.build_rel.outputs.digest }} > /tmp/digest.txt
284-
285144
- name: Upload artifact
286145
uses: actions/upload-artifact@v3
287146
with:
288147
name: digest_arm64
289148
path: /tmp/digest.txt
290-
291149
build:
292150
name: Build
293-
needs: [amd64_build, x86_build, armv7_build, arm64_build]
151+
needs: [amd64_build, x86_build, arm64_build]
294152
runs-on: ubuntu-latest
295153
steps:
296154
- name: Checkout base
@@ -315,70 +173,13 @@ jobs:
315173
with:
316174
path: /tmp/images/
317175

318-
# - name: Load image
319-
# if: github.ref == 'refs/heads/master'
320-
# run: |
321-
# docker load --input /tmp/image_amd64/image_amd64.tar
322-
# docker load --input /tmp/image_386/image_386.tar
323-
# docker load --input /tmp/image_armv7/image_armv7.tar
324-
# docker load --input /tmp/image_arm64/image_arm64.tar
325-
# docker image ls -a
326-
327-
- name: Docker login
328-
uses: docker/login-action@v2
329-
with:
330-
username: ${{ secrets.DOCKER_USERNAME }}
331-
password: ${{ secrets.DOCKER_PASSWORD }}
332-
333-
# - name: Get commit SHA
334-
# id: vars
335-
# run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
336-
337-
# - name: Docker buildx image and push on master branch
338-
# if: github.ref == 'refs/heads/master'
339-
# uses: docker/build-push-action@v3
340-
# with:
341-
# platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/386
342-
# context: scripts/
343-
# tags: tindy2013/subconverter:latest
344-
# build-args: |
345-
# SHA=${{ steps.vars.outputs.sha_short }}
346-
# THREADS=1
347-
# outputs: |
348-
# type=image,push=true
349-
350-
- name: Replace tag without `v`
351-
if: startsWith(github.ref, 'refs/tags/')
352-
uses: actions/github-script@v6
353-
id: version
176+
- name: login to ghcr.io
177+
uses: docker/login-action@v3
354178
with:
355-
script: |
356-
return context.payload.ref.replace(/\/?refs\/tags\/v/, '')
357-
result-encoding: string
358-
359-
# - name: Load release image
360-
# if: startsWith(github.ref, 'refs/tags/')
361-
# run: |
362-
# docker load --input /tmp/image_amd64/image_amd64_release.tar
363-
# docker load --input /tmp/image_386/image_386_release.tar
364-
# docker load --input /tmp/image_armv7/image_armv7_release.tar
365-
# docker load --input /tmp/image_arm64/image_arm64_release.tar
366-
# docker image ls -a
367-
368-
# - name: Docker buildx image and push on release
369-
# if: startsWith(github.ref, 'refs/tags/')
370-
# uses: docker/build-push-action@v3
371-
# with:
372-
# platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/386
373-
# context: scripts/
374-
# tags: tindy2013/subconverter:${{steps.version.outputs.result}}
375-
# build-args: THREADS=1
376-
# outputs: type=image,push=true
179+
registry: ghcr.io
180+
username: ${{ github.actor }}
181+
password: ${{ secrets.GITHUB_TOKEN }}
377182

378183
- name: Merge and push manifest on master branch
379184
if: github.ref == 'refs/heads/master'
380185
run: python scripts/merge_manifest.py
381-
382-
- name: Merge and push manifest on release
383-
if: startsWith(github.ref, 'refs/tags/')
384-
run: python scripts/merge_manifest.py ${{steps.version.outputs.result}}

scripts/merge_manifest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import glob
22
import os, sys
33

4-
MAIN_IMAGE_NAME="tindy2013/subconverter"
4+
MAIN_IMAGE_NAME="ghcr.io/metacubex/subconverter"
55
TARGET_TAG="latest" if len(sys.argv) < 2 else sys.argv[1]
66

77
args=["docker manifest create {}:{}".format(MAIN_IMAGE_NAME, TARGET_TAG)]

0 commit comments

Comments
 (0)