Update update_wiki.yml #6
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: Update Wiki | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
update-wiki: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up Git | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Clone Wiki Repository | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git wiki | |
continue-on-error: true | |
- name: Remove Old Wiki Content | |
run: | | |
echo "Removing old wiki content..." | |
rm -rf wiki/* | |
- name: Copy Files to Wiki | |
run: | | |
echo "Copying files..." | |
cp -r docs/* wiki/ | |
ls -la wiki # List files to verify copying | |
- name: Create New Home Page in Wiki | |
run: | | |
echo "Setting Introduction.md as the home page..." | |
if [ -f "wiki/_Sidebar.md" ]; then | |
echo "Updating _Sidebar.md to include Introduction.md..." | |
if ! grep -q "## Home" wiki/_Sidebar.md; then | |
echo "## Home" >> wiki/_Sidebar.md | |
fi | |
if ! grep -q "* [Home](Introduction.md)" wiki/_Sidebar.md; then | |
echo "* [Home](Introduction.md)" >> wiki/_Sidebar.md | |
fi | |
cat wiki/_Sidebar.md # Output the updated _Sidebar.md | |
else | |
echo "_Sidebar.md not found. No changes made." | |
fi | |
- name: Commit and Push Changes to Wiki | |
run: | | |
cd wiki | |
git add . | |
git commit -m "Update wiki with Introduction.md as home page and docs" || echo "No changes to commit" | |
git push | |
continue-on-error: true | |
- name: List files in wiki directory after push | |
run: ls -la wiki |