-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (135 loc) · 5.17 KB
/
publish-dogu.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
name: 📤publish-dogu
run-name: 📤publish-dogu-${{ github.event.inputs.version && github.event.inputs.version || 'rc' }}@${{ github.ref_name }}
on:
workflow_dispatch:
inputs:
rc_check:
type: boolean
description: RC version (❗ if checked, version must be empty.)
version:
type: string
description: 'Dogu image version (example: 1.0.0 ❗ if not empty, RC must be unchecked.)'
default: ''
jobs:
input-validation:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.input-validation.outputs.tag }}
temp_repo: dogutechio/dogu-temp
upload_repo: ${{ steps.input-validation.outputs.upload_repo }}
steps:
- id: input-validation
name: input validation
run: |
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'
echo "rc_check is ${{ github.event.inputs.rc_check }}"
echo "version is ${{ github.event.inputs.version }}"
rc_check=${{ github.event.inputs.rc_check }}
version=${{ github.event.inputs.version }}
if [ "$rc_check" = "true" ] && [ -n "$version" ]; then
echo -e "${RED}Skipping because rc_check is true and version is not empty${NC}"
exit 1
elif [ "$rc_check" = "false" ] && [ -z "$version" ]; then
echo -e "${RED}Skipping because rc_check is false and version is empty${NC}"
exit 1
else
if [ "$rc_check" = "true" ]; then
tag=rc
upload_repo=dogutechio/dogu-rc
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "upload_repo=${upload_repo}" >> "$GITHUB_OUTPUT"
echo -e "${GREEN} dogu upload-image-repo is ${upload_repo}${NC}"
echo -e "${GREEN} dogu upload-image-tag is ${tag}${NC}"
else
tag=${version}
upload_repo=dogutechio/dogu
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "upload_repo=${upload_repo}" >> "$GITHUB_OUTPUT"
echo -e "${GREEN} dogu upload-image-repo is ${upload_repo}${NC}"
echo -e "${GREEN} dogu upload-image-tag is ${tag}${NC}"
fi
echo -e "${GREEN} input validation successful${NC}"
fi
publish-amd64:
needs: input-validation
runs-on: ubuntu-latest
steps:
- name: docker init
run: docker system prune --volumes -a -f
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./dockerfile
push: true
target: dogu-console
platforms: linux/amd64
no-cache: true
tags: |
${{needs.input-validation.outputs.temp_repo}}:${{needs.input-validation.outputs.tag}}-amd64
publish-arm64:
needs: input-validation
runs-on: dogu-build-arm
steps:
- name: docker init
run: docker system prune --volumes -a -f
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./dockerfile
push: true
target: dogu-console
platforms: linux/arm64
no-cache: true
tags: |
${{needs.input-validation.outputs.temp_repo}}:${{needs.input-validation.outputs.tag}}-arm64
publish-menifest:
needs: [input-validation, publish-arm64, publish-amd64]
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.input-validation.outputs.tag }}
temp_repo: ${{ steps.input-validation.outputs.temp_repo }}
upload_repo: ${{ steps.input-validation.outputs.upload_repo }}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push manifest images
run: |
docker manifest create ${{needs.input-validation.outputs.upload_repo}}:${{needs.input-validation.outputs.tag}} \
${{needs.input-validation.outputs.temp_repo}}:${{needs.input-validation.outputs.tag}}-amd64 \
${{needs.input-validation.outputs.temp_repo}}:${{needs.input-validation.outputs.tag}}-arm64
docker manifest push ${{needs.input-validation.outputs.upload_repo}}:${{needs.input-validation.outputs.tag}}
send-slack:
runs-on: ubuntu-latest
needs: publish-menifest
if: ${{ always() }}
steps:
- name: Send Slack
uses: dogu-team/[email protected]
with:
template: 'CD'
slack-channel-id: 'C057ML9UH34'
result-status: ${{ needs.publish-menifest.result }}
ignore-notify: false
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}