Skip to content

Commit 53f3ede

Browse files
ci(workflows): enhance permissions for jobs (#36)
Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
1 parent 4fb6801 commit 53f3ede

File tree

3 files changed

+45
-27
lines changed

3 files changed

+45
-27
lines changed
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/main.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,25 @@ on:
1212
branches:
1313
- main
1414

15+
permissions: {}
16+
1517
jobs:
1618
build:
1719
name: Build Hugo Website
1820
if: github.event.action != 'closed'
19-
runs-on: ubuntu-latest
21+
runs-on: ubuntu-24.04
22+
timeout-minutes: 5
23+
permissions:
24+
contents: read
2025
env:
2126
GOVER: "^1.17"
2227
HUGO_ENV: production
2328
SWA_BASE: brave-pond-00b49761e
2429
steps:
2530
- name: Checkout website repo
26-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
31+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
32+
with:
33+
persist-credentials: false
2734

2835
- name: Setup Hugo
2936
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
@@ -33,7 +40,7 @@ jobs:
3340

3441
- name: Build Hugo Site
3542
run: |
36-
if [ $GITHUB_EVENT_NAME == 'pull_request' ]; then
43+
if [ "${GITHUB_EVENT_NAME}" == 'pull_request' ]; then
3744
STAGING_URL="https://${SWA_BASE}-${{github.event.number}}.3.azurestaticapps.net/"
3845
fi
3946
hugo ${STAGING_URL+-b "$STAGING_URL"}
@@ -47,8 +54,9 @@ jobs:
4754

4855
deploy:
4956
name: Deploy Hugo Website
50-
needs: ["build"]
51-
runs-on: ubuntu-latest
57+
needs: [build]
58+
runs-on: ubuntu-24.04
59+
timeout-minutes: 5
5260
environment:
5361
name: latest
5462
url: https://radapp.io
@@ -64,7 +72,7 @@ jobs:
6472
with:
6573
azure_static_web_apps_api_token: ${{ secrets.SWA_TOKEN }}
6674
skip_deploy_on_missing_secrets: true
67-
repo_token: ${{ secrets.GITHUB_TOKEN }}
75+
repo_token: ${{ github.token }}
6876
action: upload
6977
app_location: site/
7078
api_location: site/

.github/workflows/spellcheck.yaml

Lines changed: 19 additions & 10 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,28 +25,35 @@ concurrency:
2325
jobs:
2426
spellcheck:
2527
name: Spellcheck
26-
runs-on: ubuntu-latest
28+
runs-on: ubuntu-24.04
29+
timeout-minutes: 5
2730
steps:
28-
- name: Checkout docs
29-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
31+
- name: Checkout
32+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
33+
with:
34+
persist-credentials: false
3035

3136
- name: Spellcheck
3237
uses: rojopolis/spellcheck-github-actions@6f2326b663e2dbab920da0fc4144b9f3202434ba # 0.54.0
3338
with:
3439
config_path: .github/config/.pyspelling.yml
3540

36-
- name: Post GitHub workkflow output on failure
41+
- name: Post GitHub workflow output on failure
3742
if: failure()
3843
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
44+
{
45+
echo "## :x: Spellcheck Failed"
46+
echo "There are spelling errors in your PR. Visit [the workflow output](${{ env.ACTION_LINK }}) to see what words are failing."
47+
echo "### Adding new words"
48+
echo "If you are adding a new custom word refer to the [docs guide](https://docs.radapp.io/contributing/docs/#spelling)"
49+
} >> "${GITHUB_STEP_SUMMARY}"
4350
4451
- name: Post GitHub workflow output on success
4552
run: |
46-
echo "## :white_check_mark: Spellcheck Passed" >> $GITHUB_STEP_SUMMARY
47-
echo "There are no spelling errors in your PR." >> $GITHUB_STEP_SUMMARY
53+
{
54+
echo "## :white_check_mark: Spellcheck Passed"
55+
echo "There are no spelling errors in your PR."
56+
} >> "${GITHUB_STEP_SUMMARY}"
4857
4958
- name: Post GitHub comment on failure
5059
if: failure()

0 commit comments

Comments
 (0)