rusefi_documentation/.github/workflows/sync-wiki.yaml

80 lines
2.4 KiB
YAML

#
# ACCESS_TOKEN - Personal Access Token with "public_repo" permission
# If there is a change to rusefi/rusefi_documentation, this action merges it to rusefi/rusefi/wiki
#
# the opposite merge is implemented as https://github.com/rusefi/rusefi/blob/master/.github/workflows/sync-wiki.yaml
#
name: Sync Wiki & Generate static wiki
on:
push:
branches:
- master
jobs:
sync:
runs-on: ubuntu-latest
if: ${{ github.actor != 'actions-user' }}
steps:
- name: Check out docs repo
uses: actions/checkout@v2
with:
fetch-depth: 0
repository: rusefi/rusefi.wiki
persist-credentials: false
- name: Install mkdocs Prerequisites
run: |
sudo apt update
sudo apt install sshpass
pip install mkdocs mkdocs-ezlinks-plugin
- name: Merge from rusefi_documentation
run: |
git remote add technical-git https://github.com/rusefi/rusefi_documentation.git
git fetch technical-git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git merge technical-git/master
- name: GitHub LFS work-around
run: |
rm .git/hooks/pre-push
- name: Push changes rusefi/rusefi wiki
uses: ad-m/github-push-action@master
with:
repository: rusefi/rusefi.wiki
github_token: ${{ secrets.ACCESS_TOKEN }}
branch: master
- name: Generate static pages using mkdocs
run: |
shopt -s extglob
cd mkdocs
mkdir docs
cp -r ../!(mkdocs) docs
mkdocs build
- name: Set SSH variables
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
run: |
if [ "${{github.ref}}" = "refs/heads/master" ]; then
echo "::set-env name=RUSEFI_SSH_SERVER::${{secrets.RUSEFI_SSH_SERVER}}";
echo "::set-env name=RUSEFI_SSH_USER::${{secrets.RUSEFI_SSH_USER}}";
echo "::set-env name=RUSEFI_SSH_PASS::${{secrets.RUSEFI_SSH_PASS}}";
fi
- name: Upload static results to wiki3
run: |
cd mkdocs/
mv site wiki
if [ -n "$RUSEFI_SSH_SERVER" ]; then
echo "Uploading Wiki"
tar -czf - wiki | sshpass -p "$RUSEFI_SSH_PASS" ssh -o StrictHostKeyChecking=no "$RUSEFI_SSH_USER"@"$RUSEFI_SSH_SERVER" "tar -xzf - -C docs"
fi
[ $? -eq 0 ] || { echo "upload FAILED"; exit 1; }