Skip to content

fix: build file

fix: build file #16

Workflow file for this run

name: Build and Deploy Docs
on:
push:
branches:
- main
- 'v*'
tags:
- 'v*'
jobs:
build-deploy-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout Product Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Variables Based on Ref
id: vars
run: |
CURRENT_REF=${GITHUB_REF##*/}
if [[ "$CURRENT_REF" == "main" ]]; then
echo "VERSION=latest" >> $GITHUB_ENV
echo "BRANCH=main" >> $GITHUB_ENV
elif [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
echo "BRANCH=$CURRENT_REF" >> $GITHUB_ENV
else
echo "VERSION=$CURRENT_REF" >> $GITHUB_ENV
echo "BRANCH=$CURRENT_REF" >> $GITHUB_ENV
fi
# Gather branches and tags, sort, remove duplicates
VERSIONS=$(git for-each-ref refs/remotes/origin refs/tags --format="%(refname:short)" | \
grep -E "^v[0-9.]+$" | sort -Vr | uniq | tr '\n' ',' | sed 's/,$//')
echo "VERSIONS=latest,$VERSIONS" >> $GITHUB_ENV
- name: Install Hugo
run: |
wget https://github.com/gohugoio/hugo/releases/download/v0.79.1/hugo_extended_0.79.1_Linux-64bit.tar.gz
tar -xzvf hugo_extended_0.79.1_Linux-64bit.tar.gz
sudo mv hugo /usr/local/bin/
- name: Prepare Config File
run: make config
- name: Checkout Docs Repo
uses: actions/checkout@v2
with:
repository: infinilabs/docs
path: docs-output
token: ${{ secrets.DOCS_DEPLOYMENT_TOKEN }}
- name: Build Documentation
run: |
OUTPUT=$(pwd)/docs-output make build
- name: Commit and Push Changes to Docs Repo
working-directory: docs-output
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "Rebuild docs for version $VERSION"
git push origin main
else
echo "No changes to commit."
fi
- name: Rebuild Docs for Latest Version (main), if not already on main
run: |
if [[ "$CURRENT_REF" != "main" ]]; then
echo "Switching to main branch and rebuilding docs for 'latest'"
git -C . checkout main
git -C . pull origin main
# Prepare Config for Main Branch Docs
make config
OUTPUT=$(pwd)/docs-output make build
# Commit and Push Latest Docs to Main in the Docs Repo
git -C docs-output config user.name "GitHub Actions"
git -C docs-output config user.email "[email protected]"
if [[ -n $(git -C docs-output status --porcelain) ]]; then
git -C docs-output add .
git -C docs-output commit -m "Rebuild docs for main branch with latest version"
git -C docs-output push origin main
else
echo "No changes to commit for main."
fi
else
echo "Current ref is 'main', skipping rebuild for 'latest'."
fi