-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (54 loc) · 1.84 KB
/
ci.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
name: Build Docker Image
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: jerray/[email protected]
with:
aliyun-cli-version: "3.0.198"
mode: AK
access-key-id: ${{ secrets.ALIBABA_CLOUD_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.ALIBABA_CLOUD_ACCESS_KEY_SECRET }}
region: cn-beijing
- id: aliyun-cr-token
name: Obtain Aliyun Container Registry credentials
run: |
aliyun cr --force --version 2016-06-07 GET /tokens > cr_token.json
TOKEN=$(jq -r '.data.authorizationToken' cr_token.json)
echo "::add-mask::$TOKEN"
echo "json<<EOF" >> $GITHUB_OUTPUT
cat cr_token.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
rm -f cr_token.json
- name: Login to Aliyun Container Registry
uses: docker/login-action@v2
with:
registry: registry.cn-beijing.aliyuncs.com
username: ${{ fromJson(steps.aliyun-cr-token.outputs.json).data.tempUserName }}
password: ${{ fromJson(steps.aliyun-cr-token.outputs.json).data.authorizationToken }}
- id: meta
uses: docker/metadata-action@v5
with:
images: |
registry.cn-beijing.aliyuncs.com/jingbh/bjut-electricity-bill
tags: |
type=edge
type=ref,event=tag
type=sha
- uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max