-
Notifications
You must be signed in to change notification settings - Fork 10
100 lines (94 loc) · 3.39 KB
/
create-images.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
name: Create images
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
# Common versions
GO_VERSION: '1.19'
jobs:
export-registry-and-tag:
runs-on: ubuntu-20.04
outputs:
registry: ${{ steps.export.outputs.registry }}
tag: ${{ steps.export.outputs.tag }}
steps:
- id: export
run: |
# registry must be in lowercase
echo "registry=$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr [:upper:] [:lower:])" >> $GITHUB_OUTPUT
echo "tag=$(echo ${GITHUB_REF#refs/tags/})" >> "$GITHUB_OUTPUT"
publish-images:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
apps: [
exporter,
server
]
needs:
- export-registry-and-tag
env:
REGISTRY: ${{ needs.export-registry-and-tag.outputs.registry }}
IMG_TAG: ${{ needs.export-registry-and-tag.outputs.tag }}
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
submodules: true
fetch-depth: 0
- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226
- name: Build and push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
with:
context: .
file: docker/${{ matrix.apps }}/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ matrix.apps }}:${{ env.IMG_TAG }}
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}
publish-chart:
runs-on: ubuntu-20.04
needs:
- export-registry-and-tag
- publish-images
env:
REGISTRY: ${{ needs.export-registry-and-tag.outputs.registry }}
IMG_TAG: ${{ needs.export-registry-and-tag.outputs.tag }}
steps:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
with:
submodules: true
fetch-depth: 0
- name: Update values.yaml
run: |
sed -i 's|repository: ghcr.io/azure/kubernetes-carbon-intensity-exporter|repository: ${{ env.REGISTRY }}|g' ./charts/carbon-intensity-exporter/values.yaml
sed -i 's/tag: ".*"/tag: "${{ env.IMG_TAG }}"/g' ./charts/carbon-intensity-exporter/values.yaml
- name: Update Chart.yaml
run: |
sed -i "s/version: .*/version: ${{ env.IMG_TAG }}/g" ./charts/carbon-intensity-exporter/Chart.yaml
sed -i "s/appVersion: .*/appVersion: ${{ env.IMG_TAG }}/g" ./charts/carbon-intensity-exporter/Chart.yaml
- name: Login to ${{ env.REGISTRY }}
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- run: |
helm package ./charts/carbon-intensity-exporter --version ${{ env.IMG_TAG }}
helm push ./carbon-intensity-exporter-${{ github.ref_name }}.tgz oci://${{ env.REGISTRY }}/charts