-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a28b13b
commit 8239ec0
Showing
22 changed files
with
290 additions
and
219 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,22 +5,24 @@ on: | |
|
||
jobs: | ||
build-api: | ||
uses: benchiverton/OnlineStore/.github/workflows/workflow-build-test-publish-dotnet.yml@main | ||
uses: benchiverton/OnlineStore/.github/workflows/workflow-build-test-publish-dotnet.yml@containerise-apps | ||
with: | ||
solution_file: "src/Api/Company.Api.sln" | ||
project_file: "src/Api/Company.Api/Company.Api.csproj" | ||
dotnet_version: 7.0.302 | ||
artifact_name: "api" | ||
self_contained: false | ||
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 | ||
uses: benchiverton/OnlineStore/.github/workflows/workflow-build-test-publish-dotnet.yml@containerise-apps | ||
with: | ||
solution_file: "src/Website/Company.Website.sln" | ||
project_file: "src/Website/Company.Website/Company.Website.csproj" | ||
dotnet_version: 7.0.302 | ||
artifact_name: "website" | ||
self_contained: true | ||
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] | ||
|
@@ -72,10 +74,10 @@ jobs: | |
shell: bash | ||
run: | | ||
mkdir terraform-outputs | ||
terraform -chdir=instance output -raw web_app_api_name > terraform-outputs/web_app_api_name.txt | ||
terraform -chdir=instance output -raw web_app_api_hostname > terraform-outputs/web_app_api_hostname.txt | ||
terraform -chdir=instance output -raw web_app_website_name > terraform-outputs/web_app_website_name.txt | ||
terraform -chdir=instance output -raw web_app_website_hostname > terraform-outputs/web_app_website_hostname.txt | ||
terraform -chdir=instance output -raw resource_group_name > terraform-outputs/resource_group_name.txt | ||
terraform -chdir=instance output -raw container_app_api_fqdn > terraform-outputs/container_app_api_fqdn.txt | ||
terraform -chdir=instance output -raw container_app_website_fqdn > terraform-outputs/container_app_website_fqdn.txt | ||
terraform -chdir=instance output -raw container_instance_monitoring_fqdn > terraform-outputs/container_instance_monitoring_fqdn.txt | ||
# -raw cannot handle null values - https://github.com/hashicorp/terraform/issues/32384 | ||
terraform -chdir=instance show -json | jq -r '.values.outputs.container_instance_monitoring_fqdn.value // ""' > container_instance_monitoring_fqdn.txt | ||
- name: Upload terraform outputs for deploy job | ||
|
@@ -99,39 +101,38 @@ jobs: | |
id: vars | ||
shell: bash | ||
run: | | ||
echo "web_app_api_name=$(cat web_app_api_name.txt)" >> $GITHUB_ENV | ||
echo "web_app_api_hostname=$(cat web_app_api_hostname.txt)" >> $GITHUB_ENV | ||
echo "web_app_website_name=$(cat web_app_website_name.txt)" >> $GITHUB_ENV | ||
echo "web_app_website_hostname=$(cat web_app_website_hostname.txt)" >> $GITHUB_ENV | ||
echo "resource_group_name=$(cat resource_group_name.txt)" >> $GITHUB_ENV | ||
echo "container_app_api_fqdn=$(cat container_app_api_fqdn.txt)" >> $GITHUB_ENV | ||
echo "container_app_website_fqdn=$(cat container_app_website_fqdn.txt)" >> $GITHUB_ENV | ||
echo "container_instance_monitoring_fqdn=$(cat container_instance_monitoring_fqdn.txt)" >> $GITHUB_ENV | ||
- name: Download API package | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: api | ||
path: ${{ github.workspace }}/api | ||
- name: Download website package | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: website | ||
path: ${{ github.workspace }}/website | ||
- name: Update website config | ||
run: echo "`jq '.Api.BasePath="https://${{ env.web_app_api_hostname }}"' ${{ github.workspace }}/website/wwwroot/appsettings.json`" > ${{ github.workspace }}/website/wwwroot/appsettings.json | ||
- name: Login via Azure CLI | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
- name: Run Azure webapp deploy for API | ||
uses: azure/webapps-deploy@v2 | ||
id: apideploy | ||
- name: Deploy api | ||
uses: azure/container-apps-deploy-action@v1 | ||
with: | ||
app-name: ${{ env.web_app_api_name }} | ||
package: ${{ github.workspace }}/api | ||
- name: Run Azure webapp deploy for website | ||
uses: azure/webapps-deploy@v2 | ||
id: websitedeploy | ||
acrName: onlinestorecontainerregistry | ||
acrUsername: ${{ secrets.ACR_USERNAME }} | ||
acrPassword: ${{ secrets.ACR_TOKEN }} | ||
containerAppName: onlinestore-api | ||
imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-api:${{ github.sha }} | ||
location: 'East US' | ||
resourceGroup: ${{ env.resource_group_name }} | ||
targetPort: 8080 | ||
environmentVariables: "OTLPEXPORTER__ENDPOINT=http://${{ env.container_instance_monitoring_fqdn }}:4317" | ||
- name: Deploy website | ||
uses: azure/container-apps-deploy-action@v1 | ||
with: | ||
app-name: ${{ env.web_app_website_name }} | ||
package: ${{ github.workspace }}/website | ||
acrName: onlinestorecontainerregistry | ||
acrUsername: ${{ secrets.ACR_USERNAME }} | ||
acrPassword: ${{ secrets.ACR_TOKEN }} | ||
containerAppName: onlinestore-website | ||
imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-website:${{ github.sha }} | ||
location: 'East US' | ||
resourceGroup: ${{ env.resource_group_name }} | ||
targetPort: 80 | ||
environmentVariables: "API__BASEPATH=https://${{ env.container_app_api_fqdn }}" | ||
- name: Post test environment information on PR | ||
uses: actions/[email protected] | ||
if: github.event_name == 'pull_request' | ||
|
@@ -141,8 +142,8 @@ jobs: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const output = `### Test environment information | ||
#### 🔗[Visit website](https://${{ env.web_app_website_hostname }}/) | ||
#### 🔗[Visit API](https://${{ env.web_app_api_hostname }}/swagger/) | ||
#### 🔗[Visit website](https://${{ env.container_app_website_fqdn }}/) | ||
#### 🔗[Visit API](https://${{ env.container_app_api_fqdn }}/swagger/) | ||
#### 🔗[Visit monitoring UI](http://${{ env.container_instance_monitoring_fqdn }}:16686) | ||
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`; | ||
|
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
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
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
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
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
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
Oops, something went wrong.