Skip to content

Commit

Permalink
chore: script federated credentials for github actions deploy to azure
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Fosli committed Sep 18, 2022
1 parent 7fa5be8 commit 61d0fb4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/review-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- review-api/**
- .github/workflows/review-api.yaml
- scripts/az-bootstrap-containerapp.bash
workflow_dispatch:

permissions:
# required for federated credentials to access azure
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/room-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- room-api/**
- .github/workflows/room-api.yaml
- scripts/az-bootstrap-containerapp.bash
workflow_dispatch:

permissions:
# required for federated credentials to access azure
Expand Down
40 changes: 40 additions & 0 deletions scripts/az-create-federated-credentials-for-deploy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -eo pipefail

printf 'Creating app for dev\n'
#az ad app create --display-name christianfosli/stellerom-dev
sleep 2
appId="$(az ad app list --display-name christianfosli/stellerom-dev --query [0].appId -o tsv)"
#az ad sp create --id "$appId"

printf 'Creating federated credentials for GitHub Actions\n'
cat << EOF > creds.json
{
"name": "github-actions-dev",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:christianfosli/stellerom:environment:Development",
"description": "Deploy to azure from GitHub actions",
"audiences": ["api://AzureADTokenExchange"]
}
EOF
az ad app federated-credential create --id "$appId" --parameters creds.json

printf 'Creating app for prod\n'
#az ad app create --display-name christianfosli/stellerom-prod
sleep 2
appId="$(az ad app list --display-name christianfosli/stellerom-prod --query [0].appId -o tsv)"
#az ad sp create --id "$appId"

printf 'Creating federated credentials for GitHub Actions\n'
cat << EOF > creds.json
{
"name": "github-actions-prod",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:christianfosli/stellerom:environment:Production",
"description": "Deploy to azure from GitHub actions",
"audiences": ["api://AzureADTokenExchange"]
}
EOF
az ad app federated-credential create --id $appId --parameters creds.json

printf '!!MANUAL STEP: Assign permissions in Azure portal\n'

0 comments on commit 61d0fb4

Please sign in to comment.