add gh-pages workflow manually #43
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches-ignore: | |
- "dependabot/**" | |
- "gh-pages/**" | |
paths: | |
- "**" | |
- "!docs/**" | |
tags: | |
- "v*" | |
pull_request: | |
branches-ignore: | |
- "dependabot/**" | |
- "gh-pages/**" | |
paths: | |
- "**" | |
- "!docs/**" | |
env: | |
CHART_VERSION: "0.0.0" | |
CHARTS_TMP_DIR: dist | |
OCI_URL: "oci://ghcr.io/${{ github.repository }}/charts" | |
LC_ALL: en_US.UTF-8 | |
MAIN_REPO: "LiferayCloud/liferay-helm-chart" | |
PUBLISH: "false" | |
SOURCE_DIR: "." | |
defaults: | |
run: | |
shell: bash | |
permissions: | |
packages: write | |
contents: write | |
jobs: | |
ci: | |
name: Build, Test, maybe Publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone the code | |
uses: actions/checkout@v4 | |
- name: Install Helm | |
run: | | |
curl -sL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | |
- name: Verify Helm Installation | |
shell: bash | |
run: | | |
helm version | |
- name: Install the latest version of Kind | |
shell: bash | |
run: | | |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 | |
chmod +x ./kind | |
sudo mv ./kind /usr/local/bin/kind | |
- name: Verify Kind Installation | |
shell: bash | |
run: | | |
kind version | |
- name: Create Kind Cluster | |
shell: bash | |
run: | | |
kind create cluster | |
- name: Run Helm Test | |
id: helm-test | |
run: | | |
helm upgrade -i liferay . | |
helm test liferay && \ | |
echo "PUBLISH=${{ (github.repository == env.MAIN_REPO) && startsWith(github.ref, 'refs/tags/') && (github.event_name != 'pull_request') }}" >> ${GITHUB_ENV} | |
- name: Calculate Chart Version | |
if: ${{ env.PUBLISH == 'true' }} | |
id: calculate-chart-version | |
run: | | |
# This is the tag name | |
echo GITHUB_REF=${{ github.ref }} | |
# This is the version | |
CHART_VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && CHART_VERSION=$(echo $CHART_VERSION | sed -e 's/^v//') | |
[ "$CHART_VERSION" == "main" ] && CHART_VERSION="0.0.0" | |
echo CHART_VERSION=$CHART_VERSION | |
echo "CHART_VERSION=${CHART_VERSION}" >> ${GITHUB_ENV} | |
- name: Package the Helm Chart | |
if: ${{ env.PUBLISH == 'true' }} | |
run: | | |
mkdir ${CHARTS_TMP_DIR} | |
helm package --version ${CHART_VERSION} -d ${CHARTS_TMP_DIR} . | |
echo "CHARTS_TMP_DIR=$(realpath $CHARTS_TMP_DIR)" >> ${GITHUB_ENV} | |
echo "SOURCE_DIR=$(realpath $SOURCE_DIR)" >> ${GITHUB_ENV} | |
- name: Log in to registry with Helm | |
if: ${{ env.PUBLISH == 'true' }} | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io/${{ github.repository }} --username ${{ github.actor }} --password-stdin | |
- name: Push Helm Charts to Github Container Registry (OCI) | |
if: ${{ env.PUBLISH == 'true' }} | |
working-directory: dist | |
run: | | |
OCI_URL=$(echo "$OCI_URL" | tr '[:upper:]' '[:lower:]') | |
for f in *.tgz ; do | |
echo "$f" | |
helm push "$f" "$OCI_URL" | |
done | |
echo "OCI_URL=$OCI_URL" >> ${GITHUB_ENV} | |
- name: Install YQ | |
if: ${{ env.PUBLISH == 'true' }} | |
run: | | |
curl -sLo ./yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
chmod +x ./yq | |
sudo mv ./yq /usr/local/bin/yq | |
- name: Test YQ Installation | |
if: ${{ env.PUBLISH == 'true' }} | |
run: | | |
yq --version | |
- name: Update and Publish the Helm Index | |
if: ${{ env.PUBLISH == 'true' }} | |
run: | | |
./.github/scripts/publish_helm_index.sh | |
env: | |
GIT_REPOSITORY: ${{ github.repository }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
INDEX_DIR: charts | |
OWNER: ${{ github.actor }} | |
PUBLISH_BRANCH: gh-pages | |
REPO_URL: "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
REPOSITORY: ${{ github.event.repository.name }} |