-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (78 loc) · 3.21 KB
/
provision-env.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
83
84
85
86
87
88
89
90
91
92
name: Provision Participant environment
on:
pull_request:
branches:
- main
paths:
- profiles/**
types:
- closed
workflow_dispatch:
inputs:
githubhandle:
required: true
type: text
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get PR creator
id: github_handle
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
if ("${{ github.event_name }}" == "pull_request") {
const pr = context.payload.pull_request;
const creator = pr.user.login;
console.log(`PR Creator: ${creator}`);
return creator;
} else {
return "${{ github.event.inputs.githubhandle }}";
}
- name: Install GH Collab
run: |
gh extension install mislav/gh-repo-collab
env:
GH_TOKEN: ${{ secrets.VSLIVE_REPOCREATE }}
- name: Create Repository
env:
GH_TOKEN: ${{ secrets.VSLIVE_REPOCREATE }}
run: |
# Create clone of this repo for user
gh repo create XpiritCommunityEvents/${{ steps.github_handle.outputs.result }} \
--public \
--template ${{ github.repository }}
- name: Set Rights to Repo
env:
GH_TOKEN: ${{ secrets.VSLIVE_REPOCREATE }}
run: |
# Add user to newly cloned repo
gh repo-collab add XpiritCommunityEvents/${{ steps.github_handle.outputs.result }} ${{ steps.github_handle.outputs.result }} --permission admin | cat
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create Azure resource
uses: Azure/[email protected]
with:
inlineScript: |
# Set variables
RESOURCE_GROUP_NAME=rg-${{ steps.github_handle.outputs.result }}
APP_SERVICE_PLAN_NAME=asp-${{ steps.github_handle.outputs.result }}
WEBAPP_CATALOG="app-${{ steps.github_handle.outputs.result }}-catalog"
WEBAPP_ORDERING="app-${{ steps.github_handle.outputs.result }}-ordering"
WEBAPP_FRONTEND="app-${{ steps.github_handle.outputs.result }}-frontend"
az group create -l eastus -n $RESOURCE_GROUP_NAME --tags vslive=2023
# Create an App Service Plan
az appservice plan create --name $APP_SERVICE_PLAN_NAME --resource-group $RESOURCE_GROUP_NAME --sku S1 --tags vslive=2023
# Create Web Apps
az webapp create --name $WEBAPP_CATALOG --resource-group $RESOURCE_GROUP_NAME --plan $APP_SERVICE_PLAN_NAME --tags vslive=2023
az webapp create --name $WEBAPP_ORDERING --resource-group $RESOURCE_GROUP_NAME --plan $APP_SERVICE_PLAN_NAME --tags vslive=2023
az webapp create --name $WEBAPP_FRONTEND --resource-group $RESOURCE_GROUP_NAME --plan $APP_SERVICE_PLAN_NAME --tags vslive=2023
- name: Run User Provisioning Script
shell: pwsh
run: |
./provisioning/gh-aad.ps1 -githubHandle ${{ steps.github_handle.outputs.result }} -AzureCredentialsJson '${{ secrets.AZURE_CREDENTIALS }}' -InitialPassword '{{ secrets.INITIALPASSWORD }}' -runLocal $false