Update summary.en.md #90
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: Update Summary Buttons | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '_includes/summary-buttons.md' | |
| - '**/summary*.md' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '_includes/summary-buttons.md' | |
| - '**/summary*.md' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-buttons: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine diff range | |
| id: diff-range | |
| run: | | |
| BEFORE_SHA="${{ github.event.before }}" | |
| AFTER_SHA="${{ github.sha }}" | |
| if [ -z "$BEFORE_SHA" ]; then | |
| BEFORE_SHA="$(git rev-list --max-parents=0 HEAD)" | |
| fi | |
| echo "before_sha=$BEFORE_SHA" >> "$GITHUB_OUTPUT" | |
| echo "after_sha=$AFTER_SHA" >> "$GITHUB_OUTPUT" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - run: npm ci | |
| - name: Replace buttons | |
| env: | |
| BEFORE_SHA: ${{ steps.diff-range.outputs.before_sha }} | |
| AFTER_SHA: ${{ steps.diff-range.outputs.after_sha }} | |
| run: | | |
| TEMPLATE_CHANGED=$(git diff --name-only "$BEFORE_SHA" "$AFTER_SHA" -- '_includes/summary-buttons.md' | wc -l | tr -d '[:space:]') | |
| mapfile -t FILES < <(git diff --name-only "$BEFORE_SHA" "$AFTER_SHA" -- '**/summary*.md') | |
| if [ "${#FILES[@]}" -eq 0 ] && [ "$TEMPLATE_CHANGED" -eq 0 ]; then | |
| echo "No changed summaries or template; skipping." | |
| exit 0 | |
| fi | |
| echo "Template changed: $TEMPLATE_CHANGED" | |
| printf 'Changed summary files:\n%s\n' "${FILES[@]}" | |
| node scripts/replace-buttons.mjs "$TEMPLATE_CHANGED" "${FILES[@]}" | |
| - name: Commit & Push if changed | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| if git log -1 --pretty=%an | grep -q "github-actions"; then | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| git commit -m "chore: update summary action buttons" | |
| git push | |
| fi |