-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (110 loc) · 3.73 KB
/
release-artifacts.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
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
name: Release Docker images and Helm Chart
# see https://github.com/helm/chart-releaser-action
on:
workflow_dispatch: { }
push:
branches:
- "main"
env:
# Default image for the Chart
DOCKER_IMAGE_NAME: mimirrules-controller
DOCKER_REGISTRY: ghcr.io/springernature/o11y-rules-telemetry-operator
DOCKER_BUILD_DIR: '.'
permissions: {}
jobs:
make:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run make all and generate definitions
run: |
# This step is not needed per se, but runs all the tests
# and generate the manifests
make
build-image:
permissions:
packages: write # needed for ghcr access
needs:
- make
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get metadata for Docker image
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ env.DOCKER_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=branch
type=sha
- name: Get appversion from chart
id: chart
run: |
awk -F':' '/^appVersion[[:blank:]]*:/{ gsub("\"","",$2); gsub(" ", "", $2); print "app-version="$2 }' charts/mimirrules-controller/Chart.yaml >> $GITHUB_OUTPUT
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and if not a PR push to Github Packages
uses: docker/build-push-action@v5
with:
context: ${{ env.DOCKER_BUILD_DIR }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ steps.meta.outputs.tags }}
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ steps.chart.outputs.app-version }}
labels: ${{ steps.meta.outputs.labels }}
release-chart:
permissions:
contents: write # to push chart release and create a release (helm/chart-releaser-action)
packages: write
needs:
- make
- build-image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Check if CRDs match
run: |
# This step is not needed per se, but runs all the tests
# and generate the manifests
# make manifests
diff -r config/crd/bases charts/mimirrules-controller/crds
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Run chart-releaser
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: "true"
- name: Push charts to GHCR
run: |
shopt -s nullglob
helm registry login ghcr.io/${GITHUB_REPOSITORY_OWNER} --username ${{ github.actor }} --password $TOKEN
for pkg in $(shopt -s nullglob;echo .cr-release-packages/*)
do
[ -z "${pkg:-}" ] && break
helm push "${pkg}" "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/charts" || echo "::warning title=Helm push::Helm push artifact to GH Registry has failed!"
done
env:
TOKEN: "${{ secrets.GITHUB_TOKEN }}"