Add B2C authentication #226
Workflow file for this run
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: "Instance - deploy test" | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
build-api: | |
uses: benchiverton/OnlineStore/.github/workflows/workflow-build-test-publish-dotnet.yml@main | |
with: | |
solution_file: "src/Api/Company.Api.sln" | |
project_file: "src/Api/Company.Api/Company.Api.csproj" | |
dotnet_version: 8.0.203 | |
dockerfile_name: "src/Api/Company.Api/dockerfile" | |
image_name: "onlinestore-api" | |
secrets: inherit | |
build-website: | |
uses: benchiverton/OnlineStore/.github/workflows/workflow-build-test-publish-dotnet.yml@main | |
with: | |
solution_file: "src/Website/Company.Website.sln" | |
project_file: "src/Website/Company.Website/Company.Website.csproj" | |
dotnet_version: 8.0.203 | |
dockerfile_name: "src/Website/Company.Website/dockerfile" | |
image_name: "onlinestore-website" | |
secrets: inherit | |
deploy-terraform-test: | |
needs: [build-api, build-website] | |
environment: test | |
env: | |
ARM_CLIENT_ID: ${{ secrets.TF_VAR_AGENT_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.TF_VAR_AGENT_CLIENT_SECRET }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.TF_VAR_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.TF_VAR_TENANT_ID }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: "./terraform" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_wrapper: false | |
- name: Login via Azure CLI | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Terraform Format | |
id: fmt | |
run: terraform -chdir=instance fmt | |
- name: Terraform Init | |
id: init | |
run: terraform -chdir=instance init -backend-config="container_name=onlinestoretfstate-test" -backend-config="key=terraform.tfstate.${{ github.head_ref }}" | |
- name: Terraform Validate | |
id: validate | |
run: terraform -chdir=instance validate -no-color | |
- name: Terraform Plan | |
id: plan | |
run: terraform -chdir=instance plan -no-color | |
env: | |
TF_VAR_location: "East US" | |
TF_VAR_environment: ${{ github.head_ref }} | |
TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} | |
TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} | |
TF_VAR_website_dns_subdomain: ${{ github.head_ref }}-website | |
TF_VAR_api_dns_subdomain: ${{ github.head_ref }}-api | |
TF_VAR_monitoring_dns_subdomain: ${{ github.head_ref }}-monitoring | |
- name: Terraform Apply | |
id: apply | |
run: terraform -chdir=instance apply -auto-approve | |
env: | |
TF_VAR_location: "East US" | |
TF_VAR_environment: ${{ github.head_ref }} | |
TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} | |
TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} | |
TF_VAR_website_dns_subdomain: ${{ github.head_ref }}-website | |
TF_VAR_api_dns_subdomain: ${{ github.head_ref }}-api | |
TF_VAR_monitoring_dns_subdomain: ${{ github.head_ref }}-monitoring | |
- name: Save terraform outputs | |
shell: bash | |
run: | | |
mkdir terraform-outputs | |
terraform -chdir=instance output -raw resource_group_name > terraform-outputs/resource_group_name.txt | |
- name: Upload terraform outputs for deploy job | |
uses: actions/upload-artifact@v3 | |
with: | |
name: terraform-outputs | |
path: terraform/terraform-outputs/ | |
deploy-app-test: | |
needs: [deploy-terraform-test] | |
environment: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download terraform outputs | |
uses: actions/download-artifact@v3 | |
with: | |
name: terraform-outputs | |
- name: Set terraform outputs as env variables | |
id: vars | |
shell: bash | |
run: | | |
echo "resource_group_name=$(cat resource_group_name.txt)" >> $GITHUB_ENV | |
- name: Login via Azure CLI | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Deploy api | |
uses: azure/container-apps-deploy-action@v1 | |
with: | |
acrName: onlinestorecontainerregistry | |
acrUsername: ${{ secrets.ACR_USERNAME }} | |
acrPassword: ${{ secrets.ACR_TOKEN }} | |
containerAppName: ${{ github.head_ref }}-onlinestore-api | |
imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-api:${{ github.sha }} | |
location: 'East US' | |
resourceGroup: onlinestore-shared-rg | |
targetPort: 8080 | |
environmentVariables: | | |
AZUREADB2C__CLIENTID=32e35208-5d68-4ffb-a09b-9846cbe44af9 | |
AZUREADB2C__AUDIENCE=32e35208-5d68-4ffb-a09b-9846cbe44af9 | |
OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ github.head_ref }}-onlinestore-monitoring:18889 | |
- name: Deploy website | |
uses: azure/container-apps-deploy-action@v1 | |
with: | |
acrName: onlinestorecontainerregistry | |
acrUsername: ${{ secrets.ACR_USERNAME }} | |
acrPassword: ${{ secrets.ACR_TOKEN }} | |
containerAppName: ${{ github.head_ref }}-onlinestore-website | |
imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-website:${{ github.sha }} | |
location: 'East US' | |
resourceGroup: onlinestore-shared-rg | |
targetPort: 80 | |
environmentVariables: | | |
API__BASEPATH=https://${{ github.head_ref }}-api.rockpal.co.uk | |
API__CLIENTID=32e35208-5d68-4ffb-a09b-9846cbe44af9 | |
AZUREADB2C__CLIENTID=051b7459-8d57-4d92-b9d4-d4a73e49095d | |
- name: Find Comment | |
uses: peter-evans/find-comment@v1 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: "### Test environment information" | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
edit-mode: replace | |
body: | | |
### Test environment information | |
#### 🔗 [Company Website](https://${{ github.head_ref }}-website.rockpal.co.uk/) | |
#### 🔗 [Company API](https://${{ github.head_ref }}-api.rockpal.co.uk/swagger/) | |
#### 🔗 [Monitoring Dashboard](https://${{ github.head_ref }}-monitoring.rockpal.co.uk/) | |
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`* |