-
Notifications
You must be signed in to change notification settings - Fork 11
152 lines (128 loc) · 6.49 KB
/
chart-preview.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
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: Helm Preview Build
on:
workflow_dispatch:
inputs:
plane-ce:
description: "Plane CE"
required: false
default: false
type: boolean
plane-enterprise:
description: "Plane Enterprise"
required: false
default: false
type: boolean
env:
PREVIEW_BUILD_FOLDER: helm-preview
AWS_ACCESS_KEY_ID: ${{ secrets.HELM_PREVIEW_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HELM_PREVIEW_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.HELM_PREVIEW_AWS_REGION }}
AWS_BUCKET: ${{ vars.HELM_PREVIEW_BUCKET }}
HELM_SUB_FOLDER: ${{ github.run_id }}
GNUPGHOME: ${{ github.workspace }}/.gnupg
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
CHART_PREFIX: ${{ github.run_id }}
BUILD_PLANE_CE: ${{ github.event.inputs.plane-ce }}
BUILD_PLANE_EE: ${{ github.event.inputs.plane-enterprise }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
path: code
- name: Configure Git
working-directory: code
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
mkdir -p helm-preview
echo "HELM_SUB_FOLDER=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
echo "CHART_PREFIX=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Set up Helm
uses: azure/setup-helm@v4
- name: Prepare GPG key #this step is for using exported keys and make your github runner
env:
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
run: |
gpg --version
mkdir -p ${{env.GNUPGHOME}}
chmod 700 ${{env.GNUPGHOME}}
# Disable the use of the gpg-agent
echo "use-agent" >> ${{env.GNUPGHOME}}/gpg.conf
echo "pinentry-mode loopback" >> ${{env.GNUPGHOME}}/gpg.conf
echo "no-tty" >> ${{env.GNUPGHOME}}/gpg.conf
echo "no-autostart" >> ${{env.GNUPGHOME}}/gpg-agent.conf
echo "allow-loopback-pinentry" >> ${{env.GNUPGHOME}}/gpg-agent.conf
echo "${{env.GPG_PASSPHRASE}}" > ${{env.CR_PASSPHRASE_FILE}}
# Import the GPG key
echo "${{ env.GPG_PRIVATE_KEY }}" | gpg --batch --yes --pinentry-mode loopback --passphrase ${{ env.GPG_PASSPHRASE }} --import
# Re-create keyring in legacy format for Helm compatibility
gpg --export-secret-keys --passphrase ${{env.GPG_PASSPHRASE}} > ${{env.GNUPGHOME}}/secring.gpg
gpg --export --passphrase ${{env.GPG_PASSPHRASE}} > ${{env.GNUPGHOME}}/pubring.gpg
chmod 400 ${{env.GNUPGHOME}}/secring.gpg
- id: build-plane-ce
if: ${{ env.BUILD_PLANE_CE == 'true' }}
name: Build Plane-CE
working-directory: code
env:
EXPORT_DIR: ${{env.PREVIEW_BUILD_FOLDER}}
CHART_REPO: plane-ce
CR_KEY: ${{ env.GPG_KEY_NAME }}
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
CR_KEYRING: ${{env.GNUPGHOME}}/secring.gpg
run: |
flatBranchName=$(echo "${{ github.ref_name}}" | sed 's/\//\-/g')
sed -i "s/name: ${{env.CHART_REPO}}/name: ${{ env.CHART_PREFIX }}-${{env.CHART_REPO}}/" charts/${{env.CHART_REPO}}/Chart.yaml
sed -i "s/description: .*/description: ${flatBranchName}/g" charts/${{env.CHART_REPO}}/Chart.yaml
# sed -i "s/version: \(.*\)/version: \1-${flatBranchName}/" charts/${{env.CHART_REPO}}/Chart.yaml
helm package --sign --key "$CR_KEY" --keyring $CR_KEYRING --passphrase-file "$CR_PASSPHRASE_FILE" charts/$CHART_REPO -u -d ${{ env.EXPORT_DIR }}/${{env.CHART_REPO}}/charts
cp charts/${{env.CHART_REPO}}/README.md ${{ env.EXPORT_DIR }}/${{env.CHART_REPO}}/${{env.CHART_REPO}}.md
helm repo index ${{ env.EXPORT_DIR }}/${{env.CHART_REPO}}
- id: build-plane-enterprise
if: ${{ env.BUILD_PLANE_EE == 'true' }}
name: Build Plane-Enterprise
working-directory: code
env:
EXPORT_DIR: ${{env.PREVIEW_BUILD_FOLDER}}
CHART_REPO: plane-enterprise
CR_KEY: ${{ env.GPG_KEY_NAME }}
CR_PASSPHRASE_FILE: ${{env.GNUPGHOME}}/gpg-passphrase
CR_KEYRING: ${{env.GNUPGHOME}}/secring.gpg
run: |
flatBranchName=$(echo "${{ github.ref_name}}" | sed 's/\//\-/g')
sed -i "s/name: ${{env.CHART_REPO}}/name: ${{ env.CHART_PREFIX }}-${{env.CHART_REPO}}/" charts/${{env.CHART_REPO}}/Chart.yaml
sed -i "s/description: .*/description: ${flatBranchName}/g" charts/${{env.CHART_REPO}}/Chart.yaml
# sed -i "s/version: \(.*\)/version: \1-${flatBranchName}/" charts/${{env.CHART_REPO}}/Chart.yaml
helm package --sign --key "$CR_KEY" --keyring $CR_KEYRING --passphrase-file "$CR_PASSPHRASE_FILE" charts/$CHART_REPO -u -d ${{ env.EXPORT_DIR }}/${{env.CHART_REPO}}/charts
cp charts/${{env.CHART_REPO}}/README.md ${{ env.EXPORT_DIR }}/${{env.CHART_REPO}}/${{env.CHART_REPO}}.md
helm repo index ${{ env.EXPORT_DIR }}/${{env.CHART_REPO}}
- name: Publish
if: ${{ env.BUILD_PLANE_CE == 'true' || env.BUILD_PLANE_EE == 'true' }}
working-directory: code
run: |
# helm repo index ${{env.PREVIEW_BUILD_FOLDER}}
touch ${{env.PREVIEW_BUILD_FOLDER}}/index.html
# echo "<p>Helm Preview Build for Branch:${{github.ref_name}}</p>" > ${{env.PREVIEW_BUILD_FOLDER}}/index.html
HTML_CONTENT="
<p>Helm Preview Build for Branch:${{github.ref_name}}</p>
<ul>"
if [ "${{ env.BUILD_PLANE_CE }}" == "true" ]; then
HTML_CONTENT="$HTML_CONTENT
<li><a href='plane-ce/'>Plane-CE</a></li>"
fi
if [ "${{ env.BUILD_PLANE_EE }}" == "true" ]; then
HTML_CONTENT="$HTML_CONTENT
<li><a href='plane-enterprise/'>Plane-Enterprise</a></li>"
fi
HTML_CONTENT="$HTML_CONTENT
</ul>"
echo $HTML_CONTENT >> ${{env.PREVIEW_BUILD_FOLDER}}/index.html
pip install awscli
aws s3 cp ${{env.PREVIEW_BUILD_FOLDER}} s3://${{env.AWS_BUCKET}}/${{ env.HELM_SUB_FOLDER }} --recursive
echo "************************************************"
echo "http://${{env.AWS_BUCKET}}.s3-website.${{env.AWS_REGION}}.amazonaws.com/${{env.HELM_SUB_FOLDER}}"
echo "************************************************"