list Zing Blog in the download table #4
This file contains hidden or 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: Sync theme releases | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "**/*.xml" | |
| workflow_dispatch: | |
| concurrency: | |
| group: sync-theme-releases | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Resolve changed themes | |
| id: changes | |
| run: | | |
| set -euo pipefail | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "mode=all" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| before="${{ github.event.before }}" | |
| if [[ -z "$before" ]]; then | |
| echo "github.event.before is empty; cannot compute XML delta" >&2 | |
| exit 1 | |
| fi | |
| if [[ "$before" =~ ^0+$ ]]; then | |
| echo "github.event.before is a zero SHA; push delta is unavailable" >&2 | |
| exit 1 | |
| fi | |
| if ! git cat-file -e "${before}^{commit}"; then | |
| echo "commit $before is not in this clone; cannot compute XML delta" >&2 | |
| exit 1 | |
| fi | |
| sync_file="$(mktemp)" | |
| delete_file="$(mktemp)" | |
| trap 'rm -f "$sync_file" "$delete_file"' EXIT | |
| while IFS=$'\t' read -r status path extra; do | |
| [[ -z "${status:-}" || -z "${path:-}" ]] && continue | |
| case "$status" in | |
| A|M) | |
| [[ "$path" == .github/* || "$path" == tmp/* ]] && continue | |
| printf '%s\n' "$path" >> "$sync_file" | |
| ;; | |
| D) | |
| [[ "$path" == .github/* || "$path" == tmp/* ]] && continue | |
| printf '%s\n' "$path" >> "$delete_file" | |
| ;; | |
| R*) | |
| [[ "$path" == .github/* || "$path" == tmp/* ]] && continue | |
| printf '%s\n' "$path" >> "$delete_file" | |
| [[ -z "${extra:-}" ]] && { | |
| echo "rename is missing destination path: $status $path" >&2 | |
| exit 1 | |
| } | |
| [[ "$extra" == .github/* || "$extra" == tmp/* ]] && continue | |
| printf '%s\n' "$extra" >> "$sync_file" | |
| ;; | |
| *) | |
| echo "unhandled git name-status: $status $path ${extra-}" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| done < <(git diff --name-status --diff-filter=AMRD -M "$before" "${{ github.sha }}" -- '*.xml') | |
| { | |
| echo "mode=delta" | |
| echo "sync<<EOF" | |
| sort -u "$sync_file" | |
| echo "EOF" | |
| echo "delete<<EOF" | |
| sort -u "$delete_file" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Sync releases | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: | | |
| set -euo pipefail | |
| chmod +x scripts/sync-theme-releases.sh | |
| args=() | |
| if [[ "${{ steps.changes.outputs.mode }}" == "all" ]]; then | |
| args+=(--all) | |
| else | |
| while IFS= read -r path; do | |
| [[ -z "$path" ]] && continue | |
| args+=(--sync "$path") | |
| done <<< "${{ steps.changes.outputs.sync }}" | |
| while IFS= read -r path; do | |
| [[ -z "$path" ]] && continue | |
| args+=(--delete "$path") | |
| done <<< "${{ steps.changes.outputs.delete }}" | |
| fi | |
| ./scripts/sync-theme-releases.sh ${args[@]+"${args[@]}"} | |
| - name: Commit README download links | |
| run: | | |
| set -euo pipefail | |
| if git diff --quiet -- README.md; then | |
| echo "README unchanged" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git commit -m "sync README download links with theme releases" | |
| git push |