-
Notifications
You must be signed in to change notification settings - Fork 153
151 lines (141 loc) · 5.23 KB
/
publish_image_chart.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
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
name: publish
on:
push:
branches:
- master
tags:
- 'v*'
env:
GHCR: ghcr.io
GCR: gcr.io
HELM_VERSION: 3.8.2
GO_VERSION: 1.20.5
NODE_VERSION: 16.13.0
jobs:
artifacts:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Determine version
run: echo "PIPECD_VERSION=$(git describe --tags --always --abbrev=7)" >> $GITHUB_ENV
# Building go modules.
- name: Build go modules
run: make build/go
# Building web.
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Update web dependencies
run: make update/web-deps
- name: Build web static
run: make build/web
# Login to push container images.
- name: Log in to GHCR
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b #v2.0.0
with:
registry: ${{ env.GHCR }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to GCR
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b #v2.0.0
with:
registry: ${{ env.GCR }}
username: _json_key
password: ${{ secrets.GCR_SA }}
# Building and pushing container images.
- name: Build and push pipecd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/pipecd/Dockerfile
tags: ${{ env.GHCR }}/pipe-cd/pipecd:${{ env.PIPECD_VERSION }}
- name: Build and push piped image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/piped/Dockerfile
tags: |
${{ env.GHCR }}/pipe-cd/piped:${{ env.PIPECD_VERSION }}
${{ env.GCR }}/pipecd/piped:${{ env.PIPECD_VERSION }}
- name: Build and push piped-okd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/piped/Dockerfile-okd
tags: ${{ env.GHCR }}/pipe-cd/piped-okd:${{ env.PIPECD_VERSION }}
- name: Build and push launcher image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/launcher/Dockerfile
tags: |
${{ env.GHCR }}/pipe-cd/launcher:${{ env.PIPECD_VERSION }}
${{ env.GCR }}/pipecd/launcher:${{ env.PIPECD_VERSION }}
- name: Build and push launcher-okd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/launcher/Dockerfile-okd
tags: ${{ env.GHCR }}/pipe-cd/launcher-okd:${{ env.PIPECD_VERSION }}
- name: Build and push pipectl image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/pipectl/Dockerfile
tags: ${{ env.GHCR }}/pipe-cd/pipectl:${{ env.PIPECD_VERSION }}
- name: Build and push helloworld image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/helloworld/Dockerfile
tags: |
${{ env.GHCR }}/pipe-cd/helloworld:${{ env.PIPECD_VERSION }}
${{ env.GCR }}/pipecd/helloworld:${{ env.PIPECD_VERSION }}
# Building and pushing Helm charts.
- name: Install helm
uses: Azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}
- name: Login to OCI using Helm
run: |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ${{ env.GHCR }} --username ${{ github.repository_owner }} --password-stdin
- name: Publish helm charts
run: |
make build/chart VERSION=${{ env.PIPECD_VERSION }}
helm push .artifacts/pipecd-${{ env.PIPECD_VERSION }}.tgz oci://${{ env.GHCR }}/pipe-cd/chart
helm push .artifacts/piped-${{ env.PIPECD_VERSION }}.tgz oci://${{ env.GHCR }}/pipe-cd/chart
helm push .artifacts/helloworld-${{ env.PIPECD_VERSION }}.tgz oci://${{ env.GHCR }}/pipe-cd/chart
# Notify PipeCD to trigger deployment via EventWatcher.
- uses: pipe-cd/actions-event-register@v1
with:
api-address: ${{ secrets.PIPECD_API_ADDRESS }}
api-key: ${{ secrets.PIPECD_API_KEY }}
event-name: helm-release
labels: helmRepo=pipecd
data: ${{ env.PIPECD_VERSION }}