135 lines
4.2 KiB
YAML
135 lines
4.2 KiB
YAML
name: Update Docs
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '.docs/**'
|
|
|
|
env:
|
|
DOCKER_REGISTRY: registry.dutchie031.net
|
|
DOCKER_IMAGE: spearhead-docs
|
|
DOCKER_TAG: latest
|
|
|
|
jobs:
|
|
## Run replacements and cleanups on the docs
|
|
prepare-docs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
## --break-system-packages is used to avoid conflicts with system-installed packages on Ubuntu runners.
|
|
- name: Install Python Pygments
|
|
run: |
|
|
python3 -m pip install --upgrade pip --break-system-packages --no-cache-dir --ignore-installed
|
|
pip install pygments --break-system-packages
|
|
|
|
- name: Highlight API code and update HTML
|
|
run: |
|
|
pygmentize -f html -l lua -O noclasses,style=monokai src/classes/api/SpearheadApiDoc.lua > .docs/web/pages/temp_api_code.html
|
|
# Insert the highlighted code into the placeholder in spearheadapi.html
|
|
sed -i '/@@API_CODE@@/r .docs/web/pages/temp_api_code.html' .docs/web/pages/spearheadapi.html
|
|
sed -i '/@@API_CODE@@/d' .docs/web/pages/spearheadapi.html
|
|
rm .docs/web/pages/temp_api_code.html
|
|
|
|
- name: Highlight API code and update HTML
|
|
run: |
|
|
pygmentize -f html -l lua -O noclasses,style=monokai ./config.lua > .docs/web/pages/temp_config_code.html
|
|
# Insert the highlighted code into the placeholder in spearheadapi.html
|
|
sed -i '/@@CONFIG_CODE@@/r .docs/web/pages/temp_config_code.html' .docs/web/pages/reference.html
|
|
sed -i '/@@CONFIG_CODE@@/d' .docs/web/pages/reference.html
|
|
rm .docs/web/pages/temp_config_code.html
|
|
|
|
- name: List files in .docs directory
|
|
run: |
|
|
echo "Listing files in .docs directory:"
|
|
ls -R .docs
|
|
|
|
- name: Upload spearhead.lua artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: spearhead-docs
|
|
path: |
|
|
./.docs/Dockerfile
|
|
./.docs/web/**/*
|
|
retention-days: 1
|
|
|
|
build-image:
|
|
runs-on: ubuntu-latest
|
|
needs: prepare-docs
|
|
steps:
|
|
|
|
# Download prepared pages from the previous job
|
|
- name: Download spearhead-docs artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: spearhead-docs
|
|
path: ./spearhead-docs
|
|
|
|
- name: DEBUG ls
|
|
run: |
|
|
ls -R ./spearhead-docs
|
|
|
|
- name: Build Docker image for docs
|
|
run: |
|
|
docker build -t ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }} ./spearhead-docs
|
|
|
|
- name: Push Docker image
|
|
run: |
|
|
docker push ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }}
|
|
|
|
|
|
deploy-container:
|
|
runs-on: ubuntu-latest
|
|
needs: build-image
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Helm
|
|
uses: azure/setup-helm@v5
|
|
with:
|
|
version: 'latest'
|
|
id: install
|
|
|
|
- name: Setup kubectl
|
|
uses: azure/setup-kubectl@v4
|
|
with:
|
|
version: 'latest'
|
|
id: install
|
|
|
|
- name: Set up Kubeconfig
|
|
run: |
|
|
mkdir -p $HOME/.kube
|
|
echo "${{ secrets.KUBECONFIG_CONTENT }}" > $HOME/.kube/config
|
|
chmod 600 $HOME/.kube/config
|
|
cat $HOME/.kube/config
|
|
|
|
- name: Run Helm upgrade/install
|
|
run: |
|
|
helm upgrade --install spearhead-docs .helm \
|
|
--namespace spearhead-docs \
|
|
--create-namespace \
|
|
--set image.repository=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }} \
|
|
--set image.tag=${{ env.DOCKER_TAG }} \
|
|
--wait
|
|
|
|
# - name: 'Deploy'
|
|
# uses: deliverybot/helm@v1
|
|
# with:
|
|
# release: spearhead-docs
|
|
# namespace: spearhead-docs
|
|
# chart: '.helm'
|
|
# value-files: >-
|
|
# [
|
|
# ".helm/values.yaml"
|
|
# ]
|
|
# env:
|
|
# KUBECONFIG_FILE: ${{ secrets.KUBECONFIG_CONTENT }}
|