-
Notifications
You must be signed in to change notification settings - Fork 3
71 lines (57 loc) · 2.14 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
name: Go package
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Update dependencies
run: go get ./...
- name: Install golint
run: sudo apt-get install -y golint
- name: Install and Run Pre-commit
uses: pre-commit/[email protected]
- name: Build
run: go build -tags=plugins -v ./...
- name: Test
run: go test -tags=plugins -v ./...
- uses: docker/setup-buildx-action@v2
- name: Prepare docker build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# shellcheck disable=SC2086
git config user.name "GitHub Actions Bot"
# shellcheck disable=SC2086
git config user.email "<>"
# shellcheck disable=SC2086
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
# shellcheck disable=SC2086
echo "DESCRIBE=$(git describe)" >> $GITHUB_ENV
if [ "$GITHUB_REF_TYPE" == "tag" ]; then
# shellcheck disable=SC2086
echo "TAGS=ghcr.io/bolt-observer/agent:$GITHUB_REF_NAME,ghcr.io/bolt-observer/agent:unstable" >> $GITHUB_ENV
elif [ "$GITHUB_REF_NAME" == "main" ]; then
# shellcheck disable=SC2086
echo "TAGS=ghcr.io/bolt-observer/agent:$GITHUB_REF_NAME,ghcr.io/bolt-observer/agent:latest,ghcr.io/bolt-observer/agent:unstable" >> $GITHUB_ENV
else
# shellcheck disable=SC2086
echo "TAGS=ghcr.io/bolt-observer/agent:unstable" >> $GITHUB_ENV
fi
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.TAGS }}
cache-from: type=gha,scope=${{ env.GITHUB_REF_NAME }}-agent
cache-to: type=gha,mode=max,scope=${{ env.GITHUB_REF_NAME }}-agent
platforms: linux/amd64,linux/arm64
build-args: |
DESCRIBE=${{ env.DESCRIBE }}