diff --git a/.github/workflows/autopush.yaml b/.github/workflows/autopush.yaml index 3e4a368eb..879f3dcf7 100644 --- a/.github/workflows/autopush.yaml +++ b/.github/workflows/autopush.yaml @@ -23,11 +23,32 @@ env: PRE_COMMIT_CACHE: ~/.cache/pre-commit jobs: + ensure_autopusher: + name: Ensure user has autopush access + runs-on: ubuntu-latest + steps: + - name: Check autopushers team membership + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.INVESTIGATOR_BOT_TOKEN }} + script: | + const team = 'autopushers'; + const teamResponse = await github.rest.teams.listMembersInOrg({ + org: context.repo.owner, + team_slug: team, + }); + const members = teamResponse.data.map((member) => member.login); + // Check if the user is a member of the team + if (!members.includes(context.actor)) { + core.setFailed(`User ${context.actor} is not a member of the ` + + `${team} team. Found: ${members.join(', ')}`); + } + pre-commit: name: Run pre-commit runs-on: group: mala-lab-pre-commit - if: github.event.sender.login == 'cbrxyz' + needs: [ensure_autopusher] steps: - name: Check out code from GitHub uses: actions/checkout@v3.0.2 diff --git a/scripts/setup.bash b/scripts/setup.bash index 51b08d21f..c4ea9b5a3 100755 --- a/scripts/setup.bash +++ b/scripts/setup.bash @@ -136,7 +136,7 @@ cm() { # potentially borrowed from forrest autopush() { - git push origin +"${1:-HEAD}":refs/heads/autopush-cameron-"$(uuidgen --random | cut -c1-8)"-citmp + git push origin +"${1:-HEAD}":refs/heads/autopush-"$USER"-"$(uuidgen --random | cut -c1-8)"-citmp } # uhhh maybe also borrowed from forrest