-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (77 loc) · 2.35 KB
/
docker-release.yml
File metadata and controls
85 lines (77 loc) · 2.35 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
name: "Build Images"
on:
release:
types: [released]
workflow_dispatch:
inputs:
tag:
description: "The tag of the image"
required: false
type: string
updateLatest:
description: "Update the tag `latest`"
required: false
default: true
type: boolean
jobs:
get-tags:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate tags
id: generate-tags
env:
INPUT_TAG: ${{ inputs.tag }}
REGISTRYS: "docker.io/dreamofice/randomapi swr.cn-south-1.myhuaweicloud.com/dreamofice/randomapi"
UPDATE_LATEST: ${{ env.GITHUB_REF_TYPE == 'tag' || inputs.updateLatest }}
run: |
update_latest=${UPDATE_LATEST};
if [ -n "${INPUT_TAG}" ]; then
tag=${INPUT_TAG};
else
sudo apt install jq -y
tag="v$(cat package.json | jq .version -j)";
fi
prefix='';
tags=''
for registry in ${REGISTRYS}; do
tags+="${prefix}${registry}:${tag}";
prefix=",";
if ${update_latest}; then
tags+="${prefix}${registry}:latest";
fi
done
echo "tags=${tags}" >> ${GITHUB_OUTPUT};
- name: Print logs
env:
TAGS: ${{ steps.generate-tags.outputs.tags }}
run: echo -e "Tags:\n${TAGS}"
outputs:
tags: ${{ steps.generate-tags.outputs.tags }}
build-image:
needs: get-tags
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Huaweicloud
uses: docker/login-action@v2
with:
registry: swr.cn-south-1.myhuaweicloud.com
username: ${{ secrets.HUAWEICLOUD_USERNAME }}
password: ${{ secrets.HUAWEICLOUD_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v3
with:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ needs.get-tags.outputs.tags }}