-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (104 loc) · 3.9 KB
/
build.yaml
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
name: Build
on:
workflow_dispatch:
push:
branches:
- master
jobs:
build:
environment: production
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 7
- name: Login to Docker
uses: docker/login-action@v2
with:
registry: registry.ap-southeast-1.aliyuncs.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Docker
uses: docker/login-action@v2
with:
registry: registry.cn-shenzhen.aliyuncs.com
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build docker image and push
uses: docker/build-push-action@v3
with:
push: true
context: .
tags: |
registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-${{ env.SHA }}
registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:latest
registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:master-${{ env.SHA }}
registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:latest
file: Dockerfile
deploy:
environment: production
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 7
- name: Install fcli
run: |
curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-v1.0.4-linux-amd64.zip
unzip fcli.zip
sudo mv fcli /usr/local/bin/
- name: Update image version
env:
ALIBABA_CLOUD_ACCESS_KEY_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }}
ALIBABA_CLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
ALIBABA_CLOUD_DEFAULT_REGION: ap-southeast-1
ALIBABA_CLOUD_ACCOUNT_ID: ${{ secrets.ALIYUN_ACCOUNT_ID }}
SHA: ${{ env.SHA }}
run: |
fcli function update -f img-opti -s kemono -g registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-$SHA
fcli function update -f img-opti-cleaner -s kemono -g registry.ap-southeast-1.aliyuncs.com/kemono/image-optimizer:master-$SHA
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: 'GitHub Actions'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'image-optimizer 已部署'
deploy-cn:
environment: production
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: benjlevesque/[email protected]
id: short-sha
with:
length: 7
- name: Install fcli
run: |
curl -o fcli.zip https://gosspublic.alicdn.com/fcli/fcli-v1.0.4-linux-amd64.zip
unzip fcli.zip
sudo mv fcli /usr/local/bin/
- name: Update image version
env:
ALIBABA_CLOUD_ACCESS_KEY_ID: ${{ secrets.ALIYUN_ACCESS_KEY_ID }}
ALIBABA_CLOUD_ACCESS_KEY_SECRET: ${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
ALIBABA_CLOUD_DEFAULT_REGION: cn-shenzhen
ALIBABA_CLOUD_ACCOUNT_ID: ${{ secrets.ALIYUN_ACCOUNT_ID }}
SHA: ${{ env.SHA }}
run: |
fcli function update -f img-opti -s kemono -g registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:master-$SHA
fcli function update -f img-opti-cleaner -s kemono -g registry.cn-shenzhen.aliyuncs.com/kemono/image-optimizer:master-$SHA
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: 'GitHub Actions'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_MESSAGE: 'image-optimizer-cn 已部署'