Feature/automation (#6)
Reviewed-on: #6 Co-authored-by: dutchie031 <timrorije@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
@@ -5,7 +5,12 @@ on:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- '_docs/**'
|
||||
- '.docs/**'
|
||||
|
||||
env:
|
||||
DOCKER_REGISTRY: registry.dutchie031.net
|
||||
DOCKER_IMAGE: spearhead-docs
|
||||
DOCKER_TAG: latest
|
||||
|
||||
jobs:
|
||||
## Run replacements and cleanups on the docs
|
||||
@@ -17,16 +22,45 @@ jobs:
|
||||
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/**/*
|
||||
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
|
||||
@@ -34,11 +68,61 @@ jobs:
|
||||
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 spearhead-docs ./_docs
|
||||
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: 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 }}
|
||||
|
||||
Reference in New Issue
Block a user