Skip to content

Commit 0f0643f

Browse files
DariuszPorowskiytimocin
authored andcommitted
ci(workflows): enhance permissions for jobs (#1627)
Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
1 parent 77cc6e7 commit 0f0643f

9 files changed

Lines changed: 131 additions & 63 deletions

File tree

.github/workflows/close-stale-prs.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ on:
1010
schedule:
1111
- cron: "0 18 * * *" # Run the workflow every day at 6PM UTC (10AM PST).
1212

13+
permissions: {}
14+
1315
jobs:
1416
stale:
15-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-24.04
18+
timeout-minutes: 5
1619
permissions:
1720
pull-requests: write
18-
1921
steps:
2022
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
2123
with:
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ concurrency:
1111
group: issue-${{ github.event.issue.number }}
1212
cancel-in-progress: false
1313

14-
# Extra permissions needed to login with Entra ID service principal via federated identity
15-
permissions:
16-
id-token: write
17-
issues: write
14+
permissions: {}
1815

1916
jobs:
2017
ado:
21-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-24.04
19+
timeout-minutes: 5
20+
permissions:
21+
id-token: write
22+
issues: write
2223
environment:
2324
name: issues
2425
steps:
@@ -36,19 +37,19 @@ jobs:
3637
run: |
3738
# The resource ID for Azure DevOps is always 499b84ac-1321-427f-aa17-267ca6975798
3839
# https://learn.microsoft.com/azure/devops/integrate/get-started/authentication/service-principal-managed-identity
39-
ADO_TOKEN=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query "accessToken" --output tsv)
40-
echo "::add-mask::$ADO_TOKEN"
41-
echo "ADO_TOKEN=$ADO_TOKEN" >> $GITHUB_ENV
40+
ADO_TOKEN=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query accessToken --output tsv)
41+
echo "::add-mask::${ADO_TOKEN}"
42+
echo "ADO_TOKEN=${ADO_TOKEN}" >> "${GITHUB_ENV}"
4243
4344
- name: Sync issue to Azure DevOps
4445
uses: danhellem/github-actions-issue-to-work-item@8d0ead9b49a65aa66dac6949b1ff149d7ef8b4de # v2.5
4546
env:
4647
ado_token: ${{ env.ADO_TOKEN }}
47-
github_token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
48+
github_token: ${{ github.token }}
4849
ado_organization: azure-octo
4950
ado_project: Incubations
50-
ado_area_path: "Incubations\\Radius"
51-
ado_iteration_path: "Incubations\\Radius"
51+
ado_area_path: Incubations\\Radius
52+
ado_iteration_path: Incubations\\Radius
5253
ado_new_state: New
5354
ado_active_state: Active
5455
ado_close_state: Closed

.github/workflows/pr-checks.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ on:
66
pull_request:
77
types: [opened, reopened, synchronize, labeled, unlabeled]
88

9+
permissions: {}
10+
911
jobs:
1012
check-do-not-merge-tag:
1113
name: Check for do-not-merge tag
12-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
15+
timeout-minutes: 5
16+
permissions:
17+
issues: read
18+
pull-requests: read
1319
steps:
1420
- name: Check for do-not-merge label
1521
uses: mheap/github-action-required-labels@8afbe8ae6ab7647d0c9f0cfa7c2f939650d22509 # v5.5.1

.github/workflows/redirect.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@ on:
1919
- "redirect/**"
2020
- ".github/workflows/redirect.yml"
2121

22+
permissions: {}
23+
2224
jobs:
2325
deploy-website:
2426
name: Deploy Redirect Website
25-
runs-on: ubuntu-latest
27+
runs-on: ubuntu-24.04
28+
timeout-minutes: 5
29+
permissions:
30+
contents: read
2631
steps:
2732
- name: Checkout repo
28-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
33+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2934
with:
3035
submodules: false
36+
persist-credentials: false
3137

3238
- name: Deploy staging site
3339
uses: Azure/static-web-apps-deploy@4d27395796ac319302594769cfe812bd207490b1 # v1
@@ -42,7 +48,10 @@ jobs:
4248
close_pr_site:
4349
name: Close PR Staging Site
4450
if: github.event_name == 'pull_request' && github.event.action == 'closed'
45-
runs-on: ubuntu-latest
51+
runs-on: ubuntu-24.04
52+
timeout-minutes: 5
53+
permissions:
54+
contents: read
4655
steps:
4756
- name: Close Pull Request
4857
id: closepullrequest

.github/workflows/release.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ on:
1111
default: ""
1212
type: string
1313

14+
permissions: {}
15+
1416
env:
1517
GITHUB_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }}
1618
GITHUB_EMAIL: radiuscoreteam@service.microsoft.com
1719
GITHUB_USER: Radius CI Bot
1820

1921
jobs:
2022
release-docs:
21-
runs-on: ubuntu-latest
23+
runs-on: ubuntu-24.04
24+
timeout-minutes: 5
25+
permissions:
26+
contents: read
2227
steps:
23-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
28+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2429
with:
2530
token: ${{ secrets.GH_RAD_CI_BOT_PAT }}
2631
ref: edge
2732
path: docs
33+
persist-credentials: false
2834

2935
- name: Configure git
3036
run: |
@@ -40,7 +46,7 @@ jobs:
4046
run: |
4147
# CHANNEL is the major and minor version of the VERSION_NUMBER (e.g. 0.1)
4248
CHANNEL="$(echo ${{ inputs.version }} | cut -d '.' -f 1,2)"
43-
echo "channel=$CHANNEL" >> $GITHUB_OUTPUT
49+
echo "channel=$CHANNEL" >> "${GITHUB_OUTPUT}"
4450
4551
- name: Release docs
4652
run: |

.github/workflows/spellcheck.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- v*.*
1515
- edge
1616

17+
permissions: {}
18+
1719
env:
1820
ACTION_LINK: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
1921

@@ -23,10 +25,16 @@ concurrency:
2325
jobs:
2426
spellcheck:
2527
name: Spellcheck
26-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-24.04
29+
timeout-minutes: 5
30+
permissions:
31+
contents: read
32+
pull-requests: write
2733
steps:
2834
- name: Checkout docs
29-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
35+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
36+
with:
37+
persist-credentials: false
3038

3139
- name: Spellcheck
3240
uses: rojopolis/spellcheck-github-actions@6f2326b663e2dbab920da0fc4144b9f3202434ba # 0.54.0
@@ -36,15 +44,19 @@ jobs:
3644
- name: Post GitHub workkflow output on failure
3745
if: failure()
3846
run: |
39-
echo "## :x: Spellcheck Failed" >> $GITHUB_STEP_SUMMARY
40-
echo "There are spelling errors in your PR. Visit [the workflow output](${{ env.ACTION_LINK }}) to see what words are failing." >> $GITHUB_STEP_SUMMARY
41-
echo "### Adding new words" >> $GITHUB_STEP_SUMMARY
42-
echo "If you are adding a new custom word refer to the [docs guide](https://docs.radapp.io/contributing/docs/#spelling)" >> $GITHUB_STEP_SUMMARY
47+
{
48+
echo "## :x: Spellcheck Failed"
49+
echo "There are spelling errors in your PR. Visit [the workflow output](${{ env.ACTION_LINK }}) to see what words are failing."
50+
echo "### Adding new words"
51+
echo "If you are adding a new custom word refer to the [docs guide](https://docs.radapp.io/contributing/docs/#spelling)"
52+
} >> "${GITHUB_STEP_SUMMARY}"
4353
4454
- name: Post GitHub workflow output on success
4555
run: |
46-
echo "## :white_check_mark: Spellcheck Passed" >> $GITHUB_STEP_SUMMARY
47-
echo "There are no spelling errors in your PR." >> $GITHUB_STEP_SUMMARY
56+
{
57+
echo "## :white_check_mark: Spellcheck Passed"
58+
echo "There are no spelling errors in your PR."
59+
} >> "${GITHUB_STEP_SUMMARY}"
4860
4961
- name: Post GitHub comment on failure
5062
if: failure()

.github/workflows/upmerge.yaml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ name: Upmerge docs to edge
2929
on:
3030
workflow_dispatch:
3131

32+
permissions: {}
33+
3234
jobs:
3335
upmerge:
3436
name: Upmerge docs to edge
35-
runs-on: ubuntu-latest
37+
runs-on: ubuntu-24.04
38+
timeout-minutes: 5
39+
permissions:
40+
contents: write
41+
pull-requests: write
3642
steps:
3743
# Checkout the edge branch
38-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
44+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3945
with:
4046
ref: edge
4147
# https://github.com/actions/checkout/issues/125#issuecomment-570254411
@@ -48,40 +54,41 @@ jobs:
4854
run: |
4955
git config --global user.email "radiuscoreteam@service.microsoft.com"
5056
git config --global user.name "Radius CI Bot"
51-
git remote set-url origin https://$GH_TOKEN@github.com/${{ github.repository }}
57+
git remote set-url origin "https://${GH_TOKEN}@github.com/${{ github.repository }}"
5258
5359
# Create a new branch from edge. This branch will be used to PR back into edge.
5460
- name: Create new branch
5561
run: |
56-
export DATE=$(date +%Y-%m-%d)
57-
export RAND=$(openssl rand -hex 2)
58-
export BRANCH_NAME=upmerge/$DATE-$RAND
59-
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
60-
git checkout -b $BRANCH_NAME
62+
DATE=$(date +%Y-%m-%d)
63+
RAND=$(openssl rand -hex 2)
64+
BRANCH_NAME="upmerge/${DATE}-${RAND}"
65+
echo "BRANCH_NAME=${BRANCH_NAME}" >> "${GITHUB_ENV}"
66+
git checkout -b "${BRANCH_NAME}"
6167
6268
# Merge changes from the github.ref branch, i.e., the branch from which the workflow is triggered. That
6369
# branch is assumed to be the current release branch, but could be any branch.
6470
# If there are no changes, stop the workflow.
6571
- name: Upmerge docs
6672
run: |
67-
export SOURCE_BRANCH=$(basename ${{ github.ref }})
73+
SOURCE_BRANCH=$(basename ${{ github.ref }})
6874
echo "Upmerging docs from $SOURCE_BRANCH to edge"
69-
git fetch origin $SOURCE_BRANCH
70-
git merge --no-commit origin/$SOURCE_BRANCH
75+
git fetch origin "${SOURCE_BRANCH}"
76+
git merge --no-commit "origin/${SOURCE_BRANCH}"
7177
git checkout edge -- docs/config.toml docs/layouts/partials/hooks/body-end.html
7278
git commit --signoff --message "Upmerge to edge"
7379
7480
if git diff --quiet edge; then
75-
echo "No changes to merge from $SOURCE_BRANCH to edge"
76-
echo "NO_CHANGES=true" >> $GITHUB_ENV
81+
echo "No changes to merge from ${SOURCE_BRANCH} to edge"
82+
echo "NO_CHANGES=true" >> "${GITHUB_ENV}"
7783
else
78-
echo "Pushing $BRANCH_NAME for PR to edge"
79-
git push --set-upstream origin $BRANCH_NAME
84+
echo "Pushing ${BRANCH_NAME} for PR to edge"
85+
git push --set-upstream origin "${BRANCH_NAME}"
8086
fi
8187
8288
# Create a PR from the new branch to edge
8389
- name: Create pull request
8490
if: env.NO_CHANGES != 'true'
8591
env:
8692
GH_TOKEN: ${{ secrets.GH_RAD_CI_BOT_PAT }}
87-
run: gh pr create --title "Upmerge to edge" --body "Upmerge to edge (kicked off by @${{ github.triggering_actor }})" --base edge --head $BRANCH_NAME
93+
run: |
94+
gh pr create --title "Upmerge to edge" --body "Upmerge to edge (kicked off by @${{ github.triggering_actor }})" --base edge --head "${BRANCH_NAME}"

.github/workflows/validate-bicep.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ on:
2828
- edge
2929
- v*
3030

31+
permissions: {}
32+
3133
jobs:
3234
build:
3335
name: Validate Bicep Code
34-
runs-on: ubuntu-latest
36+
runs-on: ubuntu-24.04
37+
timeout-minutes: 5
38+
permissions:
39+
contents: read
3540
steps:
3641
- name: Check out repo
37-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
42+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
43+
with:
44+
persist-credentials: false
3845

3946
- name: Setup and verify bicep CLI
4047
run: |

0 commit comments

Comments
 (0)