Skip to content

test-permissions

test-permissions #9

on:
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions: {}
jobs:
add-label-to-pr:
runs-on: ubuntu-latest
concurrency:
group: example-label
permissions:
pull-requests: write # for `gh pr edit`
steps:
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr --repo "${GITHUB_REPOSITORY}" edit "1" --add-label "example-label"
remove-label-from-pr:
needs: [ add-label-to-pr ]
if: needs.add-label-to-pr.result == 'success'
concurrency:
group: example-label
permissions:
pull-requests: write # for `gh pr edit`
runs-on: ubuntu-latest
steps:
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr --repo "${GITHUB_REPOSITORY}" edit "1" --remove-label "example-label"
push-git-branch:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
touch test.txt
git checkout -b ${BRANCH}
git add test.txt
git commit -m "test"
git push -u origin ${BRANCH}
env:
BRANCH: "test-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"