From 54d66088676c5be07d3aaa257d1beb6207fe6668 Mon Sep 17 00:00:00 2001 From: warp-core Date: Thu, 20 Jun 2024 08:59:59 +0100 Subject: [PATCH] feat(ci): Add action to deploy wiki updates (#10115) --- .github/workflows/cd_wiki.yaml | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/cd_wiki.yaml diff --git a/.github/workflows/cd_wiki.yaml b/.github/workflows/cd_wiki.yaml new file mode 100644 index 000000000000..67fb2b80f728 --- /dev/null +++ b/.github/workflows/cd_wiki.yaml @@ -0,0 +1,55 @@ +name: Wiki CD + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +concurrency: + group: 'wiki-cd' + +jobs: + + cd_wiki: + name: Wiki deployment + runs-on: ubuntu-latest + if: ${{ github.repository == 'endless-sky/endless-sky' && github.ref == 'refs/heads/master' }} + permissions: + contents: write + steps: + - name: Checkout endless-sky-wiki repository + run: | + git clone "https://github.com/endless-sky/endless-sky-wiki.git" + - name: Checkout wiki + run: git clone "https://github.com/${{ github.repository }}.wiki.git" + - name: Synchronize files + run: rsync --delete -rvh -e .git endless-sky-wiki/wiki/* endless-sky.wiki/ + - name: Check for changes + id: check-diff + run: | + cd endless-sky.wiki + git add . + if [[ $(git diff --cached --raw) ]]; then + echo "changes=yes" >> "$GITHUB_OUTPUT" + fi + - name: Get latest commit hash + if: ${{ steps.check-diff.outputs.changes == 'yes' }} + id: latest-commit + run: | + cd endless-sky-wiki + echo "hash=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + - name: Commit changes + if: ${{ steps.check-diff.outputs.changes == 'yes' }} + run: | + cd endless-sky.wiki + git config --local user.name "GitHub Actions" + git config --local user.email "actions@github.com" + git commit -m "Synchronize with endless-sky-wiki" -m "Latest commit: endless-sky/endless-sky-wiki@${{ steps.latest-commit.outputs.hash }}" -m "Triggered by ${{ github.actor }}" + - name: Push changes + if: ${{ steps.check-diff.outputs.changes == 'yes' }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd endless-sky.wiki + git remote set-url origin "https://github-actions:${{ env.GH_TOKEN }}@github.com/${{ github.repository }}.wiki.git" + git push origin