Skip to content

Commit ab3fad1

Browse files
committed
Cleanup self-hosted runners: switch Azure login logic to our own
We now have our own simple workflow to log into Azure, using "az login". As we're moving way from things like the Azure CLI, let's also start using our own login script instead. Signed-off-by: Dennis Ameling <[email protected]>
1 parent 582bde8 commit ab3fad1

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

.github/workflows/cleanup-self-hosted-runners.yml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,38 +21,16 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
24-
- name: Process Azure credentials
25-
uses: actions/github-script@v7
26-
env:
27-
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
24+
- name: Azure Login
25+
uses: ./.github/workflows/azure-login
2826
with:
29-
script: |
30-
if (!process.env.AZURE_CREDENTIALS) {
31-
core.setFailed('The AZURE_CREDENTIALS secret is required.')
32-
process.exit(1)
33-
}
34-
35-
const azureCredentials = JSON.parse(process.env.AZURE_CREDENTIALS)
36-
const {clientId, clientSecret, tenantId, subscriptionId} = azureCredentials
37-
38-
core.setSecret(clientId)
39-
core.exportVariable('AZURE_CLIENT_ID', clientId)
40-
41-
core.setSecret(clientSecret)
42-
core.exportVariable('AZURE_CLIENT_SECRET', clientSecret)
43-
44-
core.setSecret(tenantId)
45-
core.exportVariable('AZURE_TENANT_ID', tenantId)
27+
credentials: ${{ secrets.AZURE_CREDENTIALS }}
4628

47-
core.setSecret(subscriptionId)
48-
core.exportVariable('AZURE_SUBSCRIPTION_ID', subscriptionId)
4929
- name: Discover VMs to delete
5030
env:
5131
GH_APP_ID: ${{ secrets.GH_APP_ID }}
5232
GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }}
5333
run: |
54-
az login --service-principal -u ${{ env.AZURE_CLIENT_ID }} -p ${{ env.AZURE_CLIENT_SECRET }} --tenant ${{ env.AZURE_TENANT_ID }}
55-
az account set --subscription ${{ env.AZURE_SUBSCRIPTION_ID }}
5634
active_vms=$(az vm list -g ${{ secrets.AZURE_RESOURCE_GROUP }} | jq -c '.[] | {name,timeCreated}')
5735
current_time=$(date +%s)
5836
one_hour_ago=$(($current_time - 3600))

0 commit comments

Comments
 (0)