From ff9a6533c50137123ad5b7ced1ab9b5a445e5235 Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Wed, 1 Oct 2025 13:10:31 -0500 Subject: [PATCH 1/2] separating sync wiki workflow from release workflow --- .github/workflows/release.yml | 39 ++---------------------- .github/workflows/sync-wiki.yml | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/sync-wiki.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e2f56a..5e0e2f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -504,39 +504,6 @@ jobs: sync-wiki: needs: create-release if: always() && needs.create-release.result == 'success' - runs-on: ubuntu-latest - continue-on-error: true - steps: - - name: Checkout main repo - uses: actions/checkout@v4 - with: - ref: ${{ github.event.inputs.branch || github.ref }} - fetch-depth: 0 - - - name: Checkout wiki repo - run: | - git clone "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.wiki.git" wiki - - - name: Sync WIKI.md to Wiki/Home.md - run: | - set -e - SRC_FILE="WIKI.md" - DEST_FILE="wiki/Home.md" - - if [ ! -f "$SRC_FILE" ]; then - echo "No $SRC_FILE in main repo; skipping." - exit 0 - fi - - if ! cmp -s "$SRC_FILE" "$DEST_FILE"; then - echo "Changes found, updating wiki..." - cp "$SRC_FILE" "$DEST_FILE" - cd wiki - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add Home.md - git commit -m "Sync WIKI.md from main repo [skip ci]" || echo "No changes to commit" - git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.wiki.git" - else - echo "No changes in $SRC_FILE; wiki is up to date." - fi \ No newline at end of file + uses: ./.github/workflows/sync-wiki.yml + permissions: + contents: write \ No newline at end of file diff --git a/.github/workflows/sync-wiki.yml b/.github/workflows/sync-wiki.yml new file mode 100644 index 0000000..765db06 --- /dev/null +++ b/.github/workflows/sync-wiki.yml @@ -0,0 +1,53 @@ +name: Sync Wiki + +on: + workflow_dispatch: + workflow_call: + +permissions: + contents: write + +jobs: + sync-wiki: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout main repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout wiki repo + id: checkout-wiki + continue-on-error: true + run: | + if git clone "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.wiki.git" wiki; then + echo "wiki_exists=true" >> $GITHUB_OUTPUT + else + echo "wiki_exists=false" >> $GITHUB_OUTPUT + echo "::warning::Wiki repository not found. Create the first wiki page at https://github.com/${GITHUB_REPOSITORY}/wiki to enable auto-sync." + fi + + - name: Sync WIKI.md to Wiki/Home.md + if: steps.checkout-wiki.outputs.wiki_exists == 'true' + run: | + SRC_FILE="WIKI.md" + DEST_FILE="wiki/Home.md" + + if [ ! -f "$SRC_FILE" ]; then + echo "No $SRC_FILE in main repo; skipping." + exit 0 + fi + + if ! cmp -s "$SRC_FILE" "$DEST_FILE"; then + echo "Changes found, updating wiki..." + cp "$SRC_FILE" "$DEST_FILE" + cd wiki + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add Home.md + git commit -m "Sync WIKI.md from main repo [skip ci]" || echo "No changes to commit" + git push + else + echo "No changes in $SRC_FILE; wiki is up to date." + fi -- 2.47.3 From 9bfbdca25e424adadffaed9e90a76f24327ce38c Mon Sep 17 00:00:00 2001 From: Jason Ross Date: Wed, 1 Oct 2025 13:25:56 -0500 Subject: [PATCH 2/2] fixed quality issues in Github actions workflow --- .github/workflows/release.yml | 5 +++-- .github/workflows/sync-wiki.yml | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e0e2f6..bed0e2f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -505,5 +505,6 @@ jobs: needs: create-release if: always() && needs.create-release.result == 'success' uses: ./.github/workflows/sync-wiki.yml - permissions: - contents: write \ No newline at end of file + with: + branch: ${{ github.event.inputs.branch || github.ref }} + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/sync-wiki.yml b/.github/workflows/sync-wiki.yml index 765db06..45db7c5 100644 --- a/.github/workflows/sync-wiki.yml +++ b/.github/workflows/sync-wiki.yml @@ -2,7 +2,19 @@ name: Sync Wiki on: workflow_dispatch: + inputs: + branch: + description: "Branch to sync from" + required: false + default: "main" + type: string workflow_call: + inputs: + branch: + description: "Branch to sync from" + required: false + default: "main" + type: string permissions: contents: write @@ -15,6 +27,7 @@ jobs: - name: Checkout main repo uses: actions/checkout@v4 with: + ref: ${{ inputs.branch || github.ref }} fetch-depth: 0 - name: Checkout wiki repo @@ -31,6 +44,7 @@ jobs: - name: Sync WIKI.md to Wiki/Home.md if: steps.checkout-wiki.outputs.wiki_exists == 'true' run: | + set -e SRC_FILE="WIKI.md" DEST_FILE="wiki/Home.md" @@ -47,7 +61,7 @@ jobs: git config user.email "github-actions[bot]@users.noreply.github.com" git add Home.md git commit -m "Sync WIKI.md from main repo [skip ci]" || echo "No changes to commit" - git push + git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.wiki.git" else echo "No changes in $SRC_FILE; wiki is up to date." fi -- 2.47.3