|
1 |
| -# We only want to run this script manually. |
2 |
| -on: workflow_dispatch |
| 1 | +name: Azure Bicep |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch |
3 | 5 |
|
4 |
| -# Environment variables are defined in an "env" section. |
5 |
| -# We set the target environment to dev. |
6 |
| -# Open the deploy-advanced.yml file to see how we can accept user input |
7 |
| -# instead of needing to change this file to switch environments. |
8 | 6 | env:
|
9 | 7 | targetEnv: dev
|
10 | 8 |
|
11 |
| -# The overall workflow name will be Azure Bicep. This will show up in the |
12 |
| -# GitHub Action page. |
13 |
| -name: Azure Bicep |
14 | 9 | jobs:
|
15 |
| - # This script has one job: build and deploy the IaC resources |
16 | 10 | build-and-deploy:
|
17 |
| - # We run this on an Ubuntu-based GitHub hosted runner. This hosted runner |
18 |
| - # has certain software already installed, including az cli |
19 | 11 | runs-on: ubuntu-latest
|
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
20 | 16 | steps:
|
21 |
| - # Check out the code. This grabs code from the repository and |
22 |
| - # makes it available to the GitHub hosted runner. It will usually be the |
23 |
| - # first task for any workflow |
24 |
| - - uses: actions/checkout@main |
| 17 | + # Checkout code |
| 18 | + - uses: actions/checkout@main |
25 | 19 |
|
26 |
| - # Log into Azure using a federated credential. We have already set up the |
27 |
| - # federation process in a prior step, so we need to pass in the following: |
28 |
| - # Client ID = Application registration ID |
29 |
| - # Tenant ID = Application owner organization ID (previously called Tenant ID in Azure) |
30 |
| - # Subscription ID |
31 |
| - # https://github.com/azure/login |
32 |
| - |
33 |
| - with: |
34 |
| - client-id: $ |
35 |
| - tenant-id: $ |
36 |
| - subscription-id: $ |
37 |
| - # We also need to ensure that enable-AzPSSession is true. This is important for |
38 |
| - # using OIDC in Azure. If we were to pass in a client secret instead, we would not need |
39 |
| - # this setting enabled |
40 |
| - enable-AzPSSession: true |
| 20 | + # Log into Azure |
| 21 | + |
| 22 | + with: |
| 23 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 24 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 25 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 26 | + enable-AzPSSession: true |
41 | 27 |
|
42 |
| - # Deploy ARM template |
43 |
| - - name: Run ARM deploy |
44 |
| - # https://github.com/azure/arm-deploy |
45 |
| - uses: azure/arm-deploy@v1 |
46 |
| - with: |
47 |
| - subscriptionId: $ |
48 |
| - resourceGroupName: $ |
49 |
| - template: ./InfrastructureAsCode/main.bicep |
50 |
| - # Use the environment variable called targetEnv |
51 |
| - parameters: environment=$ |
| 28 | + # Deploy ARM template |
| 29 | + - name: Run ARM deploy |
| 30 | + uses: azure/arm-deploy@v1 |
| 31 | + with: |
| 32 | + subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 33 | + resourceGroupName: ${{ secrets.AZURE_RG }} |
| 34 | + template: ./src/InfrastructureAsCode/main.bicep |
| 35 | + parameters: environment=${{ env.targetEnv }} |
0 commit comments