-
Notifications
You must be signed in to change notification settings - Fork 7
105 lines (100 loc) · 2.93 KB
/
ai-proxy-cd.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
103
104
105
name: CD / AI Proxy
on:
pull_request:
branches:
- "master"
paths:
- ".github/workflows/ai-proxy-cd.yaml"
- "go/ai-proxy/**"
push:
branches:
- "master"
paths:
- ".github/workflows/ai-proxy-cd.yaml"
- "go/ai-proxy/**"
tags:
- 'go/ai-proxy/v*.*.*'
permissions:
contents: read
env:
GOPATH: /home/runner/go
GOBIN: /home/runner/go/bin
GOPROXY: "https://proxy.golang.org"
jobs:
test:
name: Unit test
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
working-directory: go/ai-proxy
timeout-minutes: 5
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version-file: go/ai-proxy/go.mod
cache: true
- run: go mod download
- run: PATH=$PATH:$GOPATH/bin make --directory=.. tools
- run: PATH=$PATH:$GOPATH/bin make test
publish-docker:
name: Build and push ai-proxy container
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
working-directory: go/ai-proxy
needs: [ test ]
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/pluralsh/ai-proxy
gcr.io/pluralsh/ai-proxy
docker.io/pluralsh/ai-proxy
tags: |
type=sha
type=ref,event=pr
type=ref,event=branch
type=match,pattern=go/ai-proxy/(v.*),group=1
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: 'projects/${{ secrets.GOOGLE_PROJECT_ID }}/locations/global/workloadIdentityPools/github/providers/github'
service_account: '[email protected]'
token_format: 'access_token'
create_credentials_file: true
- uses: google-github-actions/[email protected]
- run: gcloud auth configure-docker -q
- uses: docker/login-action@v3
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- uses: docker/setup-qemu-action@v3
- uses: docker/[email protected]
- uses: docker/[email protected]
with:
context: "./go/ai-proxy"
file: "./go/ai-proxy/Dockerfile"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GIT_COMMIT=${{ github.sha }}
VERSION=${{ steps.meta.outputs.version }}