-
Notifications
You must be signed in to change notification settings - Fork 68
80 lines (68 loc) · 2.26 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: CI
on:
push:
branches:
- master
jobs:
setup:
runs-on: ubuntu-latest
outputs:
timestamp: ${{ steps.set_timestamp.outputs.timestamp }}
steps:
- name: Set timestamp
id: set_timestamp
run: |
TIMESTAMP=$(TZ=Asia/Shanghai date +%Y-%m-%d.%H-%M-%S)
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
arch:
- amd64
- arm64
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Aliyun Hub
uses: docker/login-action@v3
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.OPSRE_ALIHUB_USERNAME }}
password: ${{ secrets.OPSRE_ALIHUB_TOKEN }}
- name: Set env variables
id: set_env
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "SHORT_SHA=${GITHUB_SHA:0:4}" >> $GITHUB_ENV
echo "DATE=${{ needs.setup.outputs.timestamp }}" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' }}
build-args: |
VERSION=${{ env.DATE }}
TARGETARCH=${{ matrix.arch }}
tags: |
cairry/watchalert:latest
cairry/watchalert:${{ env.BRANCH_NAME }}.${{ env.DATE }}.${{ env.SHORT_SHA }}
registry.cn-hangzhou.aliyuncs.com/opsre/watchalert:latest
registry.cn-hangzhou.aliyuncs.com/opsre/watchalert:${{ env.BRANCH_NAME }}.${{ env.DATE }}.${{ env.SHORT_SHA }}