name: Teams on: schedule: # Every Monday at 19:42 (randomly chosen) - cron: '42 19 * * 1' workflow_dispatch: permissions: {} defaults: run: shell: bash jobs: sync: if: github.event_name != 'schedule' || github.repository_owner == 'NixOS' runs-on: ubuntu-slim steps: # Use a GitHub App to create the PR so that CI gets triggered and to # request team member lists. - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 id: app-token with: client-id: ${{ vars.NIXPKGS_CI_CLIENT_ID }} private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }} permission-administration: read permission-contents: write permission-members: read permission-pull-requests: write - name: Fetch source uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 with: persist-credentials: false sparse-checkout: | ci/github-script maintainers/github-teams.json - name: Install dependencies run: npm ci --package-lock-only=false bottleneck working-directory: ci/github-script - name: Synchronise teams uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: github-token: ${{ steps.app-token.outputs.token }} script: | require('./ci/github-script/get-teams.js')({ github, context, core, outFile: "maintainers/github-teams.json" }) - name: Get GitHub App User Git String id: user env: GH_TOKEN: ${{ steps.app-token.outputs.token }} APP_SLUG: ${{ steps.app-token.outputs.app-slug }} run: | name="${APP_SLUG}[bot]" userId=$(gh api "/users/$name" --jq .id) email="$userId+$name@users.noreply.github.com" echo "git-string=$name <$email>" >> "$GITHUB_OUTPUT" - name: Create Pull Request uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: token: ${{ steps.app-token.outputs.token }} add-paths: maintainers/github-teams.json author: ${{ steps.user.outputs.git-string }} committer: ${{ steps.user.outputs.git-string }} commit-message: "maintainers/github-teams.json: Automated sync" branch: pr/github-team-sync title: "maintainers/github-teams.json: Automated sync" body: | This is an automated PR to sync the GitHub teams with access to this repository to the `lib.teams` list. This PR can be merged without taking any further action.