forked from endless-sky/endless-sky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): Add action to deploy wiki updates (endless-sky#10115)
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "[email protected]" | ||
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 |