-
Notifications
You must be signed in to change notification settings - Fork 11
161 lines (148 loc) · 5 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
name: ci/cd
permissions:
contents: read
id-token: write
on:
pull_request: {}
push:
branches:
- master
tags:
- v*
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- uses: golangci/golangci-lint-action@v6
test:
strategy:
matrix:
go: ["1.22.x", "1.21.x"]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
restore-keys: |
go-
- run: make test
build-and-push-alpha:
if: startsWith(github.head_ref, 'bump-version-')
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ROLE_TO_ASSUME }}
role-session-name: "mackerel-container-agent-${{ github.run_id }}-${{ github.run_number }}"
aws-region: ap-northeast-1
- name: Login to Public ECR
uses: docker/login-action@v3
with:
registry: public.ecr.aws
env:
AWS_REGION: us-east-1
- name: Get alpha version from branch name
id: get_alpha_version
run: echo "::set-output name=VERSION::${GITHUB_HEAD_REF/bump-version-/v}"
- name: Build and push alpha image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: container-agent
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
mackerel/mackerel-container-agent:${{ steps.get_alpha_version.outputs.VERSION }}-alpha
public.ecr.aws/mackerel/mackerel-container-agent:${{ steps.get_alpha_version.outputs.VERSION }}-alpha
- name: Build and push alpha image with plugins
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: container-agent-with-plugins
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
mackerel/mackerel-container-agent:${{ steps.get_alpha_version.outputs.VERSION }}-plugins-alpha
public.ecr.aws/mackerel/mackerel-container-agent:${{ steps.get_alpha_version.outputs.VERSION }}-plugins-alpha
build-and-push-release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ROLE_TO_ASSUME }}
role-session-name: "mackerel-container-agent-${{ github.run_id }}-${{ github.run_number }}"
aws-region: ap-northeast-1
- name: Login to Public ECR
uses: docker/login-action@v3
with:
registry: public.ecr.aws
env:
AWS_REGION: us-east-1
- name: Get version from tag
id: get_version
run: echo "::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}"
- name: Build and push release image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: container-agent
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
mackerel/mackerel-container-agent:latest
mackerel/mackerel-container-agent:${{ steps.get_version.outputs.VERSION }}
public.ecr.aws/mackerel/mackerel-container-agent:latest
public.ecr.aws/mackerel/mackerel-container-agent:${{ steps.get_version.outputs.VERSION }}
- name: Build and push release image with plugins
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
target: container-agent-with-plugins
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
mackerel/mackerel-container-agent:plugins
mackerel/mackerel-container-agent:${{ steps.get_version.outputs.VERSION }}-plugins
public.ecr.aws/mackerel/mackerel-container-agent:plugins
public.ecr.aws/mackerel/mackerel-container-agent:${{ steps.get_version.outputs.VERSION }}-plugins