33
33
POST_DEPLOYMENT_SCRIPT_URL : https://raw.githubusercontent.com/${{ github.repository }}/${{ github.ref_name }}/azure-self-hosted-runners/post-deployment-script.ps1
34
34
35
35
# The following secrets are required for this workflow to run:
36
- # GH_API_PAT - PAT to create a runner registration token using GitHub's API
37
36
# AZURE_CREDENTIALS - Credentials for the Azure CLI. It's recommended to set up a resource
38
37
# group specifically for self-hosted Actions Runners.
39
38
# az ad sp create-for-rbac --name "{YOUR_DESCRIPTIVE_NAME_HERE}" --role contributor \
70
69
VM_NAME="actions-runner-$(date +%Y%m%d%H%M%S%N)"
71
70
echo "Will be using $VM_NAME as the VM name"
72
71
echo "vm_name=$VM_NAME" >> $GITHUB_OUTPUT
72
+ - uses : actions/checkout@v3
73
+ - name : Obtain installation token
74
+ id : setup
75
+ uses : actions/github-script@v6
76
+ with :
77
+ script : |
78
+ const appId = ${{ secrets.GH_APP_ID }}
79
+ const privateKey = `${{ secrets.GH_APP_PRIVATE_KEY }}`
80
+
81
+ const getAppInstallationId = require('./get-app-installation-id')
82
+ const installationId = await getAppInstallationId(
83
+ console,
84
+ appId,
85
+ privateKey,
86
+ process.env.ACTIONS_RUNNER_ORG,
87
+ process.env.ACTIONS_RUNNER_REPO
88
+ )
73
89
90
+ const getInstallationAccessToken = require('./get-installation-access-token')
91
+ const accessToken = await getInstallationAccessToken(
92
+ console,
93
+ appId,
94
+ privateKey,
95
+ installationId
96
+ )
97
+
98
+ core.setSecret(accessToken)
99
+ core.setOutput('token', accessToken)
74
100
# We can't use the octokit/request-action as we can't properly mask the runner token with it
75
101
# https://github.com/actions/runner/issues/475
76
102
- name : Generate Actions Runner token and registration URL
93
119
ACTIONS_RUNNER_TOKEN=$(curl \
94
120
-X POST \
95
121
-H "Accept: application/vnd.github+json" \
96
- -H "Authorization: Bearer ${{ secrets.GH_API_PAT }}"\
122
+ -H "Authorization: Bearer ${{ steps.setup.outputs.token }}"\
97
123
-H "X-GitHub-Api-Version: 2022-11-28" \
98
124
$ACTIONS_API_URL \
99
125
| jq --raw-output .token)
@@ -105,9 +131,6 @@ jobs:
105
131
with :
106
132
creds : ${{ secrets.AZURE_CREDENTIALS }}
107
133
108
- # Checkout the repo so that we can access the template files
109
- - uses : actions/checkout@v3
110
-
111
134
- uses : azure/arm-deploy@v1
112
135
with :
113
136
resourceGroupName : ${{ secrets.AZURE_RESOURCE_GROUP }}
0 commit comments