Skip to content

Helm Preview Build

Helm Preview Build #26

Workflow file for this run

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 }}
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
working-directory: code
run: |
gpg_dir=.cr-gpg
mkdir "$gpg_dir"
keyring="$gpg_dir/secring.gpg" #referring keyring to private key of gpg
base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring" #storing base64 GPG key into keyring
passphrase_file="$gpg_dir/passphrase"
echo "$GPG_PASSPHRASE" > "$passphrase_file" #storing passphrase data into a file
echo "CR_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV" #saving passphrase into github-environment
echo "CR_KEYRING=$keyring" >> "$GITHUB_ENV" #saving private key into github-environemnt
env:
GPG_KEYRING_BASE64: "${{ secrets.GPG_KEYRING_BASE64 }}" #Referring secrets of github above
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
- 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
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 "Plane" --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
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 "Plane" --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 "************************************************"