-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (64 loc) · 2.36 KB
/
learn-github-actions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
on:
workflow_dispatch:
inputs:
location:
description: 'azure location'
required: true
default: 'eastus2'
push:
branches:
- main
- dev
# GitHub Actions workflow to deploy to Azure using azd
# To configure required secrets for connecting to Azure, simply run `azd pipeline config`
# Set up permissions for deploying with secretless Azure federated credentials
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
permissions:
id-token: write
contents: read
jobs:
RunHooks:
runs-on: ubuntu-latest
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
steps:
- name: Checkout
uses: actions/checkout@v4
# - name: Install azd
# uses: Azure/setup-azd@v1.0.0
- name: Install azd
run: |
curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version daily
- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh
- name: Configure template
run: |
azd version
echo ${{ env.AZURE_SUBSCRIPTION_ID }}
echo ${{ secrets.AZURE_SUBSCRIPTION_ID }}
echo ${{ vars.AZURE_LOCATION }}
azd config set defaults.subscription ${{ env.AZURE_SUBSCRIPTION_ID }}
azd config set defaults.location ${{ env.AZURE_LOCATION }}
environmentName="sdk-azdhook-$(uuidgen | cut -c 1-6)"
azd init -e $environmentName
# - name: Provision Infrastructure
# run: azd provision --no-prompt
# env:
# AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
# - name: Deploy Application
# run: azd deploy --no-prompt
- name: Run azd hooks
run: |
set -e
chmod -R +x ./hooks/
azd up --no-prompt
azd down --purge --force