-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (96 loc) · 3.15 KB
/
push.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
name: Push
on:
workflow_dispatch: {}
push:
branches:
- main
env:
GO_VERSION: 1.20.10
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
BUILD_TIME: ${{ steps.buildinfo.outputs.BUILD_TIME }}
BUILD_VERSION: ${{ steps.buildinfo.outputs.BUILD_VERSION }}
BUILD_REVISION: ${{ steps.buildinfo.outputs.BUILD_REVISION }}
steps:
- name: checkout
uses: actions/checkout@v2
- name: calculate build version
id: buildinfo
run: |
SHORT_SHA=${GITHUB_SHA::8}
VERSION=${GITHUB_REF_NAME}
echo "BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "BUILD_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "BUILD_REVISION=${SHORT_SHA}" >> $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
needs:
- prepare
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: setup cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore_keys: |
${{ runner.os }}-go-
- name: install dependencies
run: |
go mod download
- name: run tests
run: |
go test -v ./...
build:
runs-on: ubuntu-latest
needs:
- prepare
- test
steps:
- name: checkout
uses: actions/checkout@v2
- name: setup buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64
- name: login to ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: login to aliyuncr
uses: docker/login-action@v2
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIYUNCR_USERNAME }}
password: ${{ secrets.ALIYUNCR_PASSWORD }}
- name: build
uses: docker/build-push-action@v3
with:
push: true
platforms: linux/amd64
build-args: |
BUILD_TIME=${{ needs.prepare.outputs.BUILD_TIME }}
BUILD_VERSION=${{ needs.prepare.outputs.BUILD_VERSION }}
BUILD_REVISION=${{ needs.prepare.outputs.BUILD_REVISION }}
tags: |
ghcr.io/imulab/wetriage:latest
ghcr.io/imulab/wetriage:${{ needs.prepare.outputs.BUILD_VERSION }}
ghcr.io/imulab/wetriage:${{ needs.prepare.outputs.BUILD_REVISION }}
registry.cn-hangzhou.aliyuncs.com/elan-vision/wetriage:latest
registry.cn-hangzhou.aliyuncs.com/elan-vision/wetriage:${{ needs.prepare.outputs.BUILD_VERSION }}
registry.cn-hangzhou.aliyuncs.com/elan-vision/wetriage:${{ needs.prepare.outputs.BUILD_REVISION }}
labels: |
org.opencontainers.image.title="WeTriage"
org.opencontainers.image.source="https://github.com/imulab/WeTriage"
org.opencontainers.image.authors="Weinan Qiu"