Skip to content

Docs by released binaries #59

Docs by released binaries

Docs by released binaries #59

Workflow file for this run

name: Docs by released binaries
on:
workflow_run:
workflows:
- Build binaries for release
types:
- completed
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract commit author information
id: author_info
run: |
COMMIT_AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
COMMIT_AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
echo "AUTHOR_NAME=$COMMIT_AUTHOR_NAME" >> $GITHUB_ENV
echo "AUTHOR_EMAIL=$COMMIT_AUTHOR_EMAIL" >> $GITHUB_ENV
- name: Set up Git
run: |
git config --global user.name "${{ env.AUTHOR_NAME }}"
git config --global user.email "${{ env.AUTHOR_EMAIL }}"
- name: Clone wiki repository
run: |
git clone https://${{ github.repository_owner }}:${{ secrets.GH_PAT }}@github.com/${{ github.repository }}.wiki.git wiki
- name: Install Pandoc
run: |
sudo apt-get update
sudo apt-get install -y pandoc
- name: Install Go
run: |
GO_VERSION=${{ vars.GO_VERSION }}
wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go version
- name: Build documentation as Markdown
run: |
go run . run docs
- name: Cleanup wiki folder and copy markdown files
run: |
rm -rf wiki/*
cp -R docs/* wiki/
cp wiki/gpm.md wiki/Home.md
- name: Convert Markdown to HTML and update links
run: |
for mdfile in docs/*.md; do
htmlfile="${mdfile%.md}.html"
pandoc -f markdown "$mdfile" -o "$htmlfile"
if [ $? -eq 0 ]; then
# replace .md links to .html
sed -i 's/href="\(.*\)\.md"/href="\1.html"/g' "$htmlfile"
echo "Converted $mdfile to $htmlfile"
rm "$mdfile"
else
echo "Failed to convert $mdfile" >&2
exit 1
fi
done
- name: Fix permissions
run: sudo chmod -R 777 docs/
- name: Check docs directory contents
run: sudo ls -al docs
- name: Upload directory
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
source: "docs"
target: ${{ secrets.SSH_SOURCEDIR }}
- name: Move to target
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
sudo rm -rf ${{ secrets.SSH_TARGETDIR }}/* &>/dev/null
sudo mv ${{ secrets.SSH_SOURCEDIR }}/docs/* ${{ secrets.SSH_TARGETDIR }} &>/dev/null
sudo chown -R ${{ secrets.SERVER_USERNAME }}:${{ secrets.SERVER_GROUP }} ${{ secrets.SSH_TARGETDIR }}/* &>/dev/null
sudo chmod -R 644 ${{ secrets.SSH_TARGETDIR }}/* &>/dev/null
sudo chmod 744 ${{ secrets.SSH_TARGETDIR }}/ &>/dev/null
script_stop: true
- name: Push update to wiki
working-directory: wiki
run: |
git add .
git commit -m "Update triggered by #${{ github.sha }}" || true
git push