generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 4
113 lines (97 loc) · 3.85 KB
/
generate-manifest.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
# This job will generate manifest
name: Generate Manifests
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
type: string
required: true
upload_url:
type: string
required: false
env:
MANIFEST_FILENAME: manager_manifest.yaml
CR_FILENAME: manager_default_CR.yaml
defaults:
run:
shell: bash
jobs:
generate_manifest:
name: Generate manifest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version and upload URL
id: get_version_upload_url
run: |
if [[ ! -z '${{ inputs.version }}' ]]
then
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
fi
if [[ ! -z '${{ inputs.upload_url }}' ]]
then
echo "upload_url=${{ inputs.upload_url }}" >> $GITHUB_OUTPUT
elif [[ ! -z '${{ github.event.release.upload_url }}' ]]
then
echo "upload_url=${{ github.event.release.upload_url }}" >> $GITHUB_OUTPUT
else
echo "upload_url=''" >> $GITHUB_OUTPUT
fi
- name: Print version
run: |
echo "Version=${{ steps.get_version_upload_url.outputs.version }}"
- name: Update version in kustomization.yaml & default CRO
run: |
yq -i '.images[0].newTag="${{ steps.get_version_upload_url.outputs.version }}"' config/default/kustomization.yaml
yq -i '.labels[0].pairs."app.kubernetes.io/version"="${{ steps.get_version_upload_url.outputs.version }}"' config/default/kustomization.yaml
yq -i '.metadata.labels."app.kubernetes.io/version"="${{ steps.get_version_upload_url.outputs.version }}"' config/samples/operator_v1alpha1_capoperator.yaml
- name: Download kustomize cli
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
chmod +x kustomize
- name: Generate Manifests
run: |
./kustomize build config/default/ > $MANIFEST_FILENAME
cat $MANIFEST_FILENAME
cat config/samples/operator_v1alpha1_capoperator.yaml > $CR_FILENAME
- name: Determine target commit
id: get_target_commit
run: |
sha=$(git rev-parse HEAD)
echo "Target commit: $sha"
echo "sha=$sha" >> $GITHUB_OUTPUT
- name: Wait for check suites to complete
uses: sap-contributions/await-check-suites@master
if: inputs.version == ''
with:
ref: ${{ steps.get_target_commit.outputs.sha }}
intervalSeconds: 10
timeoutSeconds: 1800
failStepIfUnsuccessful: true
appSlugFilter: github-actions
- name: Upload manifest & default CR to release
if: inputs.upload_url != '' || github.event.release.upload_url != ''
run: |
upload_url="${{ steps.get_version_upload_url.outputs.upload_url }}"
upload_url=${upload_url%%\{*\}}
file=$MANIFEST_FILENAME
echo "Uploading manifest $file to $upload_url ..."
curl -sSf \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @$file \
"$upload_url?name=$(basename $file)"
file=$CR_FILENAME
echo "Uploading default CR $file to $upload_url ..."
curl -sSf \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Content-Type: $(file -b --mime-type $file)" \
--data-binary @$file \
"$upload_url?name=$(basename $file)"