Skip to content

Commit 69304ce

Browse files
ci(deploy): add OIDC token authentication for Azure deployment
Add permissions block (id-token, contents, pull-requests), install @actions/core and @actions/http-client for OIDC, fetch an ID token via actions/github-script, and pass it to the Azure deploy step. Co-Authored-By: Hagicode <noreply@hagicode.com> Signed-off-by: newbe36524 <newbe36524@qq.com>
1 parent 19f45f2 commit 69304ce

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

.github/workflows/azure-static-web-apps-agreeable-stone-04924c800.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
if: github.event.action != 'closed'
2626
runs-on: ubuntu-latest
2727
name: Build and Deploy Job
28+
permissions:
29+
id-token: write
30+
contents: read
31+
pull-requests: write
2832
steps:
2933
- uses: actions/checkout@v4
3034
with:
@@ -40,6 +44,18 @@ jobs:
4044
- name: Install dependencies
4145
run: npm ci
4246

47+
- name: Install OIDC Client from Core Package
48+
run: npm install @actions/core@1.6.0 @actions/http-client
49+
50+
- name: Get Id Token
51+
uses: actions/github-script@v6
52+
id: idtoken
53+
with:
54+
script: |
55+
const coredemo = require('@actions/core');
56+
return await coredemo.getIDToken();
57+
result-encoding: string
58+
4359
- name: Build docs
4460
run: npm run build:ci
4561
env:
@@ -55,6 +71,7 @@ jobs:
5571
app_location: dist
5672
skip_app_build: true
5773
skip_api_build: true
74+
github_id_token: ${{ steps.idtoken.outputs.result }}
5875

5976
close_pull_request_job:
6077
if: github.event_name == 'pull_request' && github.event.action == 'closed'

0 commit comments

Comments
 (0)