on: workflow_call: inputs: SOURCE_REF: description: "Commit SHA that was pushed to ncmr-songs" required: true type: string SOURCE_BASE_REF: description: "Commit SHA before the push (empty or all-zeros = first push)" required: true type: string jobs: publish: runs-on: ubuntu-latest container: image: pi5-16.local:3005/novoyuuparosk-wiki/novoyuuparosk-wiki-runner:4f134af steps: - name: Checkout ncmr-songs env: FAPAT: ${{ secrets.FAPAT }} URL_TO_GITEA: ${{ vars.URL_TO_GITEA }} SOURCE_REF: ${{ inputs.SOURCE_REF }} run: | git clone "http://mikkeli:${FAPAT}@${URL_TO_GITEA#http://}/novoyuuparosk-wiki/ncmr-songs" ncmr-songs git -C ncmr-songs checkout "$SOURCE_REF" - name: Checkout auto-wiki env: FAPAT: ${{ secrets.FAPAT }} URL_TO_GITEA: ${{ vars.URL_TO_GITEA }} run: git clone "http://mikkeli:${FAPAT}@${URL_TO_GITEA#http://}/novoyuuparosk-wiki/novoyuuparosk-auto-wiki" auto-wiki # The diff bounds what gets *written*, not what gets *read*. The publisher # always scans the whole repository to resolve links and page titles, then # writes only these files (plus, one hop out, any page they link to or that # links to them). Passing a subset here is safe for that reason and only # that reason — resolution no longer depends on the batch. - name: Detect changed files id: diff env: BASE: ${{ inputs.SOURCE_BASE_REF }} HEAD: ${{ inputs.SOURCE_REF }} run: | # Empty or all-zeros base means first push or manual dispatch — publish everything if [ -z "$BASE" ] || echo "$BASE" | grep -qE '^0+$'; then echo "First push or manual dispatch — publishing everything." echo "mode=all" >> "$GITHUB_OUTPUT" exit 0 fi CHANGED=$(git -C ncmr-songs diff --name-only "$BASE" "$HEAD" -- '*.md' | grep -v '^wip/' || true) echo "Changed files:" echo "$CHANGED" echo "mode=incremental" >> "$GITHUB_OUTPUT" echo "files=$(echo "$CHANGED" | tr '\n' ' ')" >> "$GITHUB_OUTPUT" - name: Publish env: WIKI_API_URL: ${{ vars.WIKI_API_URL }} WIKI_BASE_URL: ${{ vars.WIKI_BASE_URL }} WIKI_BOT_USER: ${{ secrets.WIKI_BOT_USER }} WIKI_BOT_PASSWORD: ${{ secrets.WIKI_BOT_PASSWORD }} SOURCE_REF: ${{ inputs.SOURCE_REF }} GITEA_REPO_URL: ${{ vars.PUBLIC_URL_TO_GITEA }}/novoyuuparosk-wiki/ncmr-songs MODE: ${{ steps.diff.outputs.mode }} FILES: ${{ steps.diff.outputs.files }} run: | if [ "$MODE" = "all" ]; then python auto-wiki/pipelines/songs/publish.py --source-dir ncmr-songs --all elif [ -n "$(echo "$FILES" | tr -d '[:space:]')" ]; then # shellcheck disable=SC2086 python auto-wiki/pipelines/songs/publish.py --source-dir ncmr-songs --files $FILES else echo "No changed .md files outside wip/. Nothing to publish." fi