Skip to content

Commit 9bb460a

Browse files
authored
JS-1594 Move ESLint README freshness to nightly (#6857)
1 parent 690d8a1 commit 9bb460a

1 file changed

Lines changed: 46 additions & 106 deletions

File tree

.github/workflows/build.yml

Lines changed: 46 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
merge_group:
1010
workflow_dispatch:
1111
schedule:
12-
- cron: '0 0 * * *' # Nightly for analyze and iris tasks
12+
- cron: '0 0 * * *' # Nightly for analysis, IRIS, and ESLint README freshness
1313

1414
concurrency:
1515
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -279,10 +279,7 @@ jobs:
279279
needs: [setup, populate_npm_cache, sync_rspec]
280280
name: Build ESLint Plugin
281281
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
282-
permissions:
283-
id-token: write
284-
contents: write
285-
pull-requests: write
282+
permissions: *read_permissions
286283
steps:
287284
- *checkout
288285
- *mise
@@ -303,114 +300,57 @@ jobs:
303300
run: npm run eslint-plugin:build
304301
env:
305302
GITHUB_TOKEN: ${{ fromJSON(steps.rspec-secrets.outputs.vault).RSPEC_GITHUB_TOKEN }}
306-
- name: Check README freshness
307-
if: github.event_name == 'pull_request'
308-
env:
309-
GH_TOKEN: ${{ github.token }}
310-
GITHUB_TOKEN: ${{ fromJSON(steps.rspec-secrets.outputs.vault).RSPEC_GITHUB_TOKEN }}
311-
PR_NUMBER: ${{ github.event.pull_request.number }}
312-
HEAD_REF: ${{ github.head_ref }}
313-
run: |
314-
# Check if last commit was already an auto-update (prevent infinite loop)
315-
LAST_COMMIT_MSG=$(git log -1 --format=%B)
316-
if echo "$LAST_COMMIT_MSG" | grep -q "🤖 Generated with GitHub Actions"; then
317-
echo "Last commit was an auto-update, skipping to prevent infinite loop"
318-
exit 0
319-
fi
320-
321-
RULES_README="packages/analysis/src/jsts/rules/README.md"
322-
323-
# Make git@github.com transport use token auth during generate-meta (sync-rspec).
324-
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "git@github.com:"
325-
326-
# Regenerate metadata and check for differences only on the rules README
327-
npm run generate-meta
328-
329-
FIX_BRANCH="fix/update-readme-for-${HEAD_REF}"
330-
331-
if git diff --quiet -- "$RULES_README"; then
332-
echo "README is up to date"
333-
334-
# Clean up stale fix PR if one exists and is still open
335-
FIX_PR_STATE=$(gh pr view "$FIX_BRANCH" --json state --jq '.state' 2>/dev/null || true)
336-
if [ "$FIX_PR_STATE" = "OPEN" ]; then
337-
gh pr close "$FIX_BRANCH" --comment "No longer needed — the original PR is now up to date."
338-
git push origin --delete "$FIX_BRANCH" 2>/dev/null || true
339-
fi
340-
341-
exit 0
342-
fi
343-
344-
echo "README is stale — creating fix PR"
345-
346-
git stash push -m "readme-update" -- "$RULES_README"
347-
git fetch origin "$HEAD_REF"
348-
git config user.name "github-actions[bot]"
349-
git config user.email "github-actions[bot]@users.noreply.github.com"
350-
351-
if git ls-remote --exit-code origin "refs/heads/$FIX_BRANCH" > /dev/null 2>&1; then
352-
git checkout -b "$FIX_BRANCH" "origin/$HEAD_REF"
353-
git stash pop
354-
git add "$RULES_README"
355-
if git diff --cached --quiet -- "$RULES_README"; then
356-
echo "README is up to date on the PR head branch"
357-
exit 0
358-
fi
359-
git commit -m "Update rules README
360-
361-
🤖 Generated with GitHub Actions"
362-
git push --force-with-lease origin "$FIX_BRANCH"
363-
FIX_PR_URL=$(gh pr view "$FIX_BRANCH" --json url --jq '.url')
364-
else
365-
git checkout -b "$FIX_BRANCH" "origin/$HEAD_REF"
366-
git stash pop
367-
git add "$RULES_README"
368-
if git diff --cached --quiet -- "$RULES_README"; then
369-
echo "README is up to date on the PR head branch"
370-
exit 0
371-
fi
372-
git commit -m "Update rules README
373-
374-
🤖 Generated with GitHub Actions"
375-
git push origin "$FIX_BRANCH"
376-
FIX_PR_URL=$(gh pr create \
377-
--title "Update rules README for PR #${PR_NUMBER}" \
378-
--base "$HEAD_REF" \
379-
--head "$FIX_BRANCH" \
380-
--body "Auto-generated README update for PR #${PR_NUMBER}.
381-
382-
🤖 Generated with GitHub Actions")
383-
fi
384-
385-
# Comment on original PR with link to fix PR
386-
MARKER="<!-- readme-freshness -->"
387-
COMMENT_BODY="${MARKER}
388-
## README Freshness Check
389-
390-
❌ **The rules README is out of date.**
391-
392-
A fix PR has been created: ${FIX_PR_URL}
393-
394-
Please review and merge it into your branch."
395-
396-
EXISTING_COMMENT_ID=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
397-
--jq ".[] | select(.body | startswith(\"$MARKER\")) | .id" | head -1)
398-
399-
if [ -n "$EXISTING_COMMENT_ID" ]; then
400-
gh api "repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT_ID" \
401-
-X PATCH -F body="$COMMENT_BODY"
402-
else
403-
gh pr comment "$PR_NUMBER" --body "$COMMENT_BODY"
404-
fi
405-
406-
exit 1
407303
- &eslint_tarball_cache
408304
name: Cache ESLint plugin tarball
409305
uses: SonarSource/gh-action_cache@v1
410306
with:
411307
path: lib/*.tgz
412308
key: eslint-tarball-${{ github.sha }}
413309

310+
eslint_readme_freshness:
311+
runs-on: github-ubuntu-latest-s
312+
needs: [setup, populate_npm_cache, sync_rspec]
313+
name: ESLint README Freshness
314+
if: github.event_name == 'schedule'
315+
permissions:
316+
id-token: write
317+
contents: write
318+
pull-requests: write
319+
steps:
320+
- *checkout
321+
- *mise
322+
- id: secrets
323+
name: Access vault secrets
324+
uses: SonarSource/vault-action-wrapper@v3
325+
with:
326+
secrets: |
327+
development/artifactory/token/${{ github.repository_owner }}-${{ github.event.repository.name }}-private-reader access_token | ARTIFACTORY_ACCESS_TOKEN;
328+
- name: Configure npm registry
329+
run: |
330+
npm config set //repox.jfrog.io/artifactory/api/npm/:_authToken=${{ fromJSON(steps.secrets.outputs.vault).ARTIFACTORY_ACCESS_TOKEN }}
331+
npm config set registry https://repox.jfrog.io/artifactory/api/npm/npm/
332+
- *npm_cache
333+
- *download_rspec_rule_data
334+
- *rspec_secrets
335+
- name: Regenerate ESLint README
336+
env:
337+
GITHUB_TOKEN: ${{ fromJSON(steps.rspec-secrets.outputs.vault).RSPEC_GITHUB_TOKEN }}
338+
run: |
339+
git config --global url."https://x-access-token:${GITHUB_TOKEN}@github.com/".insteadOf "git@github.com:"
340+
npm install --no-save builtin-modules@3.3.0
341+
npm run eslint-plugin:compile
342+
- name: Open or update README refresh PR
343+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8
344+
with:
345+
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
346+
commit-message: Update eslint-plugin-sonarjs README
347+
title: Update eslint-plugin-sonarjs README
348+
body: Automated refresh of `packages/analysis/src/jsts/rules/README.md`.
349+
branch: bot/update-eslint-rules-readme
350+
base: master
351+
add-paths: packages/analysis/src/jsts/rules/README.md
352+
delete-branch: true
353+
414354
test_eslint_plugin:
415355
runs-on: github-ubuntu-latest-s
416356
name: ESLint Plugin Test - ESLint ${{ matrix.eslint-version }} Node ${{ matrix.node-version }}

0 commit comments

Comments
 (0)