Repository navigation
150 lines (130 loc) · 4.08 KB
/
Copy pathdocker-image.yml
File metadata and controls
150 lines (130 loc) · 4.08 KB
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
name: Build and Publish Subpool Image
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
- main
workflow_dispatch:
inputs:
platforms:
description: Target architectures (use native amd64 when ARM emulation is unavailable)
type: choice
default: linux/amd64,linux/arm64
options:
- linux/amd64,linux/arm64
- linux/amd64
permissions:
contents: read
concurrency:
group: subpool-image-${{ github.ref }}
cancel-in-progress: true
jobs:
go-test:
name: Test Go service
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres:17-alpine
env:
POSTGRES_USER: subpool
POSTGRES_PASSWORD: test
POSTGRES_DB: subpool_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U subpool -d subpool_test"
--health-interval 5s
--health-timeout 3s
--health-retries 10
env:
SUBPOOL_TEST_DATABASE_URL: postgres://subpool:test@localhost:5432/subpool_test?sslmode=disable
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run Go tests
run: go test ./...
web-test:
name: Test and build web console
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: web/package-lock.json
- name: Install web dependencies
working-directory: web
run: npm ci
- name: Run web tests
working-directory: web
run: npm test
- name: Build web console
working-directory: web
run: npm run build
- name: Test release pages
working-directory: pages
run: npm test
- name: Build release pages offline
working-directory: pages
run: npm run build:offline
build:
name: Build Subpool image
needs:
- go-test
- web-test
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up QEMU
if: github.event_name != 'pull_request'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
if: github.event_name != 'pull_request'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_AK }}
aws-secret-access-key: ${{ secrets.AWS_SK }}
aws-region: us-east-1
- name: Log in to ECR Public
if: github.event_name != 'pull_request'
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: public.ecr.aws/cloudpilotai/subpool
tags: |
type=raw,value=latest,enable=${{ github.ref_name == github.event.repository.default_branch && (github.event_name != 'workflow_dispatch' || inputs.platforms != 'linux/amd64') }}
type=ref,event=branch,enable=${{ github.event_name != 'workflow_dispatch' || inputs.platforms != 'linux/amd64' }}
type=ref,event=tag
type=raw,value=sha-${{ github.sha }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ github.event_name == 'pull_request' && 'linux/amd64' || inputs.platforms || 'linux/amd64,linux/arm64' }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=subpool
cache-to: type=gha,scope=subpool,mode=max