Skip to content

Commit

Permalink
.github/workflows/autopush.yaml: Use autopushers team membership for …
Browse files Browse the repository at this point in the history
…autopushing perms instead of hardcoded cameron permissions
  • Loading branch information
cbrxyz committed Jan 8, 2025
1 parent de839f9 commit 0ccffc1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion .github/workflows/autopush.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0ccffc1

Please sign in to comment.