From a30b24817f06239b107f0858dcccedeba97f8af2 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 17 Jul 2024 20:19:27 +0200 Subject: [PATCH] fixup! tools: add workflow to ensure `README` lists are in sync with gh teams --- .github/workflows/linters-readme.yml | 17 ++++++++++++----- .github/workflows/linters.yml | 7 ------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/linters-readme.yml b/.github/workflows/linters-readme.yml index af999d565ea031..d300f3a1880761 100644 --- a/.github/workflows/linters-readme.yml +++ b/.github/workflows/linters-readme.yml @@ -3,7 +3,8 @@ name: Linters (README.md) on: - pull_request: + # We need `pull_request_target` to access the secrets + pull_request_target: types: [opened, synchronize, reopened, ready_for_review] paths: [README.md] push: @@ -30,20 +31,26 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: persist-credentials: false - - name: Get ${{ env.TEAM }} team members + ref: ${{ github.event.repository.default_branch }} + - name: Get team members id: team_members run: | get_list_members() { TEAM="$1" QUOTE='"' - gh api "/orgs/nodejs/teams/$TEAM/members" -X GET -f per_page=100 --jq "map(.login) | @sh ${QUOTE}${TEAM}=\(tojson)${QUOTE}" + gh api "/orgs/nodejs/teams/$TEAM/members" -X GET -f per_page=100 --jq "map(.login) | ${QUOTE}${TEAM}=\(tojson)${QUOTE}" } - + get_list_members "collaborators" >> "$GITHUB_OUTPUT" get_list_members "issue-triage" >> "$GITHUB_OUTPUT" get_list_members "tsc" >> "$GITHUB_OUTPUT" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_USER_TOKEN }} + - name: Get modified README + if: github.event_name != 'push' + run: | + curl -fsSLo README.md "https://raw.githubusercontent.com/nodejs/node/$GITHUB_SHA/README.md" + git diff - run: tools/lint-readme-lists.mjs "$TEAMS" env: TEAMS: ${{ tojson(steps.team_members.outputs) }} diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ed869696633a69..11b0c257537759 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -179,10 +179,3 @@ jobs: persist-credentials: false # GH Actions squashes all PR commits, HEAD^ refers to the base branch. - run: git diff HEAD^ HEAD -G"pr-url:" -- "*.md" | ./tools/lint-pr-url.mjs ${{ github.event.pull_request.html_url }} - lint-readme: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - persist-credentials: false - - run: tools/lint-readme-lists.mjs