Docs by released binaries #64
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: Docs by released binaries | |
on: | |
workflow_run: | |
workflows: | |
- Build binaries for release | |
types: | |
- completed | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/[email protected] | |
- 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: Setup 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 | |
uses: actions/[email protected] | |
with: | |
go-version: ${{ vars.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/[email protected] | |
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/[email protected] | |
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 |