Skip to content

Commit

Permalink
Merge pull request #58 from DataDog/anmarchenko/reduce_github_actions…
Browse files Browse the repository at this point in the history
…_permissions

reduce permissions for milestone github actions
  • Loading branch information
anmarchenko authored Oct 25, 2023
2 parents c4cca65 + 64e06c9 commit 9f6d671
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/add-milestone-to-pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ on:

jobs:
add_milestone_to_merged:
permissions:
issues: write
pull-requests: write
if: github.event.pull_request.merged && github.event.pull_request.milestone == null
name: Add milestone to merged pull requests
runs-on: ubuntu-latest
steps:
- name: Get project milestones
id: milestones
uses: actions/github-script@0.9.0
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const list = await github.issues.listMilestonesForRepo({
const list = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
Expand All @@ -29,12 +32,12 @@ jobs:
return milestones.length == 0 ? null : milestones[0].number
- name: Update Pull Request
if: steps.milestones.outputs.result != null
uses: actions/github-script@0.9.0
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
// Confusingly, the issues api is used because pull requests are issues
await github.issues.update({
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{ github.event.pull_request.number }},
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/create-next-milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:

jobs:
create_next_milestone:
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- name: Get next minor version
Expand Down

0 comments on commit 9f6d671

Please sign in to comment.