-
Notifications
You must be signed in to change notification settings - Fork 19
97 lines (89 loc) · 2.8 KB
/
ci.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
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- uses: actions/checkout@v2
# NOTE: using link-local reserved address block in order to avoid conflict.
- name: Add fake IP (169.196.255.254) on loopback interface
run: |-
{ ip address | grep -q 169.196.255.254; } || sudo ip address add 169.196.255.254 dev lo
- name: Running required services (Builkit, Docker Registry, Docker)
run: docker compose -f ./compose.yaml up -d
- name: Install protoc and Go compiler plugins
run: |-
sudo apt install -y protobuf-compiler
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
- run: make test test/integration
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- uses: actions/checkout@v2
- uses: golangci/golangci-lint-action@v3
publish:
if: github.repository == 'tsuru/deploy-agent' && github.event_name != 'pull_request'
needs:
- lint
- test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: Surgo/docker-smart-tag-action@v1
id: smarttag
with:
docker_image: tsuru/deploy-agent
default_branch: main
tag_with_sha: 'true'
- name: Handle smart-tag to proper tag var
uses: actions/github-script@v6
id: handle_tag
with:
script: |
var tag_re = /deploy-agent:([0-9])/g
var orig_tags = `${{steps.smarttag.outputs.tag}}`
return orig_tags.replace(tag_re,"deploy-agent:v$1")
- name: docker login
uses: docker/login-action@v3
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: push image tag to Docker Hub (tsuru/deploy-agent)
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.handle_tag.outputs.result }}
platforms: linux/amd64,linux/arm64
release:
if: github.event_name != 'pull_request' && github.repository == 'tsuru/deploy-agent' && startsWith(github.ref, 'refs/tags/')
needs:
- lint
- test
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: goreleaser/goreleaser-action@v2
with:
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}