Test Issue #84
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Provision Participant environment | |
on: | |
issues: | |
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 issue creator | |
id: github_handle | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
if ("${{ github.event_name }}" == "issues") { | |
const subject = context.payload.issue; | |
if (subject.labels.find(l => l.name == "signup")) { | |
creator = subject.user.login; | |
console.log(`Issue creator: ${creator}`); | |
return creator; | |
} | |
throw new Error("Issue did not have a signup label"); | |
} | |
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 | |
repo_name="XpiritCommunityEvents/attendeec2c-${{ steps.github_handle.outputs.result }}" | |
if gh repo view $repo_name &>/dev/null; then | |
echo "Repository $repo_name already exists." | |
else | |
echo "Repository $REPO_NAME does not exist." | |
gh repo create $repo_name \ | |
--public \ | |
--template ${{ github.repository }} | |
fi | |
- name: Set Rights to Repo | |
env: | |
GH_TOKEN: ${{ secrets.VSLIVE_REPOCREATE }} | |
run: | | |
# Add user to newly cloned repo | |
gh repo-collab add XpiritCommunityEvents/attendeec2c-${{ 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 |