forked from cedadev/jasmin-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (136 loc) · 4.81 KB
/
build-push-artifacts.yaml
File metadata and controls
154 lines (136 loc) · 4.81 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
151
152
153
154
name: Publish artifacts
# Run the tasks on every push
on: push
jobs:
build_push_api:
name: Build and push API image
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set up Docker layer caching
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-api-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-api-
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate metadata for image
id: image-meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/stackhpc/jasmin-cloud-api
# Produce the branch name or tag and the SHA as tags
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,prefix=
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: ./api
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
# https://github.com/docker/buildx/pull/535
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build_push_ui:
name: Build and push UI image
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Set up Docker layer caching
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-ui-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-ui-
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate metadata for image
id: image-meta
uses: docker/metadata-action@v3
with:
images: ghcr.io/stackhpc/jasmin-cloud-ui
# Produce the branch name or tag and the SHA as tags
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,prefix=
- name: Build and push image
uses: docker/build-push-action@v2
with:
context: ./ui
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.image-meta.outputs.tags }}
labels: ${{ steps.image-meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
# https://github.com/docker/buildx/pull/535
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
build_push_chart:
name: Build and push Helm chart
runs-on: ubuntu-latest
# Only build and push the chart if the images built successfully
needs: [build_push_api, build_push_ui]
steps:
- name: Check out the repository
uses: actions/checkout@v2
with:
# This is important for "git rev-list --count" to work correctly when
# determining the number of commits since the last tag
fetch-depth: 0
- name: Login to GitHub Container Registry
env:
HELM_EXPERIMENTAL_OCI: "1"
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: echo "$PASSWORD" | helm registry login --username "$USERNAME" --password-stdin "$REGISTRY"
# This action packages and pushes the chart
- name: Package and push chart
env:
HELM_EXPERIMENTAL_OCI: "1"
CHART_DIRECTORY: ./chart
CHART_REPOSITORY: ghcr.io/stackhpc/jasmin-cloud-chart
run: ./scripts/build-push-chart.py