Skip to content

Commit

Permalink
Merge pull request #1 from nlykkei/website-url-env-output
Browse files Browse the repository at this point in the history
Website URL Output
  • Loading branch information
nlykkei authored Jul 15, 2024
2 parents befb74a + d1c7c3e commit 37fd439
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Build Application
name: Build

on:
workflow_call:

jobs:
build-application:
build-app:
name: Build application
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
required: true

jobs:
deploy-application:
deploy-app:
name: Deploy application
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
Expand All @@ -27,7 +27,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: application
- name: Azure Login
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ on:
required: true

jobs:
validate:
name: Validate
validate-infra:
name: Validate infrastructure
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Azure Login
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Preflight validation
- name: Run preflight validation
uses: azure/arm-deploy@v2
with:
deploymentName: ${{ github.run_number }}
Expand All @@ -55,8 +55,8 @@ jobs:
failOnStdErr: false
if: inputs.environment == 'production'

deploy:
name: Deploy
deploy-infra:
name: Deploy infrastructure
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
outputs:
Expand All @@ -65,13 +65,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Azure Login
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy
- name: Deploy infrastructure
uses: azure/arm-deploy@v2
id: deploy
with:
Expand All @@ -84,23 +84,23 @@ jobs:
deploymentMode: Complete
failOnStdErr: false
- name: Website URL
run: 'echo "Website URL 🚀: https://${{ steps.deploy.outputs.appServiceAppHostName }}" >> "${GITHUB_STEP_SUMMARY}"'
needs: [validate]
run: 'echo "Website URL (${{ inputs.environment }}) 🚀: https://${{ steps.deploy.outputs.appServiceAppHostName }}" >> "${GITHUB_STEP_SUMMARY}"'
needs: [validate-infra]

deploy-application:
deploy-app:
name: Deploy application
uses: ./.github/workflows/deploy-app.yml
with:
environment: ${{ inputs.environment }}
appServiceAppName: ${{ needs.deploy.outputs.appServiceAppName }}
appServiceAppName: ${{ needs.deploy-infra.outputs.appServiceAppName }}
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
needs: [deploy]
needs: [deploy-infra]

# smoke-test:
# name: Smoke tests
# name: Run smoke tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
Expand All @@ -113,4 +113,4 @@ jobs:
# -Container $container `
# -CI
# shell: pwsh
# needs: [deploy, deploy-application]
# needs: [deploy-infra, deploy-app]
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:

jobs:
lint:
name: Lint
name: Lint infrastructure
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint
- name: Lint infrastructure
run: |
az bicep build --file infra/main.bicep
24 changes: 12 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ permissions:
# https://learn.microsoft.com/en-us/training/modules/manage-end-end-deployment-scenarios-using-bicep-github-actions/3-configure-applications-virtual-machines

jobs:
build:
name: Build
uses: ./.github/workflows/build.yml

lint:
name: Lint
lint-infra:
name: Lint infrastructure
uses: ./.github/workflows/lint.yml

deploy-test:
name: Deploy [test]
build-app:
name: Build application
uses: ./.github/workflows/build.yml

deploy-infra-test:
name: Deploy infrastructure [test]
uses: ./.github/workflows/deploy.yml
with:
environment: test
Expand All @@ -36,10 +36,10 @@ jobs:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
needs: [build, lint]
needs: [lint-infra, build-app]

deploy-production:
name: Deploy [production]
deploy-infra-prod:
name: Deploy infrastructure [prod]
uses: ./.github/workflows/deploy.yml
with:
environment: production
Expand All @@ -48,4 +48,4 @@ jobs:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
needs: [deploy-test]
needs: [deploy-infra-test]
37 changes: 37 additions & 0 deletions .github/workflows/pr-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Todo App PR Closed

concurrency:
group: ${{ github.event.number }}
cancel-in-progress: false

on:
pull_request:
branches:
- main
types: [closed]

permissions:
id-token: write
contents: read

env:
resourceGroupName: pr_${{ github.event.number }}

jobs:
delete-infra:
name: Delete infrastructure
runs-on: ubuntu-latest
steps:
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Delete infrastructure
uses: azure/cli@v2
with:
inlineScript: |
az group delete \
--name ${{ env.resourceGroupName }} \
--yes
33 changes: 17 additions & 16 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ env:
# https://learn.microsoft.com/en-us/training/modules/automate-azure-infrastructure-change-reviews-using-bicep-github/6-exercise-create-ephemeral-environments-pull-requests

jobs:
build:
name: Build
uses: ./.github/workflows/build.yml

lint:
name: Lint
lint-infra:
name: Lint infrastructure
uses: ./.github/workflows/lint.yml

deploy:
name: Deploy
build-app:
name: Build application
uses: ./.github/workflows/build.yml

deploy-infra:
name: Deploy infrastructure
runs-on: ubuntu-latest
environment: test
outputs:
Expand All @@ -38,7 +38,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Azure Login
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -53,27 +53,28 @@ jobs:
--location ${{ env.resourceGroupLocation }}
- uses: azure/arm-deploy@v2
id: deploy
name: Deploy
name: Deploy infrastructure
with:
deploymentName: ${{ github.run_number }}
scope: resourceGroup
scope: resourcegroup
resourceGroupName: ${{ env.resourceGroupName }}
template: ./deploy/main.bicep
template: ./infra/main.bicep
parameters: >
environment=test
deploymentMode: Complete
failOnStdErr: false
- name: Website URL
run: 'echo "Website URL 🚀: https://${{ steps.deploy.outputs.appServiceAppHostName }}" >> "${GITHUB_STEP_SUMMARY}"'
run: 'echo "Website URL (test) 🚀: https://${{ steps.deploy.outputs.appServiceAppHostName }}" >> "${GITHUB_STEP_SUMMARY}"'
needs: [lint-infra, build-app]

deploy-application:
deploy-app:
name: Deploy application
uses: ./.github/workflows/deploy-app.yml
with:
environment: test
appServiceAppName: ${{ needs.deploy.outputs.appServiceAppName }}
appServiceAppName: ${{ needs.deploy-infra.outputs.appServiceAppName }}
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
needs: [deploy]
needs: [deploy-infra]

0 comments on commit 37fd439

Please sign in to comment.