Skip to content

Commit

Permalink
Merge pull request #21 from Azure-Samples/fix-broken-app-template
Browse files Browse the repository at this point in the history
Fix broken app template
  • Loading branch information
kpantos authored Dec 12, 2024
2 parents 4cc7624 + 32500a7 commit 7fbeec0
Show file tree
Hide file tree
Showing 21 changed files with 490 additions and 1,186 deletions.
141 changes: 50 additions & 91 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,62 @@ name: WordPress Deployment
on:
workflow_dispatch:
push:
# Run when commits are pushed to mainline branch
# Set this to the mainline branch you are using
branches:
- main
pull_request:
branches:
- main
- master
schedule:
- cron: "0 10 * * 6"

# Set this permission if you are using a Federated Credential.
permissions:
id-token: write
contents: read


# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The lint job performs linting on the bicep code
lint:
# The type of runner that the job will run on
Test:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
# azd build-in variables.
# This variables are always set by `azd pipeline config`
# You can set them as global env (apply to all steps) or you can add them to individual steps' environment
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
# This env var is required only by the first step that uses azd (provision, up, deploy, etc) to create the env config
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
## Define the additional variables or secrets that are required globally (provision and deploy)

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4

# Runs the Bicep linter to ensure build is successful
- name: Run Bicep linter
run: az bicep build --file ./infra/main.bicep
# using the install-azd action
- name: Install azd
uses: Azure/[email protected]

validate:
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Sign in to Azure
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: azure/[email protected]
name: Run preflight validation
with:
deploymentName: ${{ github.run_number }}
scope: subscription
region: ${{ vars.AZURE_LOCATION }}
template: ./infra/main.bicep
parameters: environmentName=${{ vars.AZURE_ENV_NAME }}
location=${{ vars.AZURE_LOCATION }}
fqdn=${{ vars.AZURE_FQDN }}
applicationName=${{ vars.AZURE_APPLICATION_NAME }}
mariaDBPassword=${{ secrets.AZURE_MARIADB_PASSWORD }}
adminUsername=${{ vars.AZURE_ADMIN_USERNAME }}
adminPassword=${{ secrets.AZURE_ADMIN_PASSWORD }}
redisDeploymentOption=${{ vars.AZURE_REDIS_DEPLOYMENTOPTIONS }}
deploymentMode: Validate
# # If you want to use azd-daily build, or install it from a PR, you can remove previous step and
# # use the next one:
# - name: Install azd - daily or from PR
# # Update this scrip based on the OS - pool of your pipeline. This example is for a linux pipeline installing daily build
# run: curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version daily
# shell: pwsh

preview:
runs-on: ubuntu-latest
needs: [lint, validate]
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Sign in to Azure
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: Azure/cli@v1
name: Run what-if
with:
azcliversion: 2.45.0
inlineScript: |
az deployment sub what-if \
--location ${{ vars.AZURE_LOCATION }} \
--template-file ./infra/main.bicep \
--parameters environmentName=${{ vars.AZURE_ENV_NAME }} \
--parameters location=${{ vars.AZURE_LOCATION }} \
--parameters fqdn=${{ vars.AZURE_FQDN }} \
--parameters applicationName=${{ vars.AZURE_APPLICATION_NAME }} \
--parameters mariaDBPassword=${{ secrets.AZURE_MARIADB_PASSWORD }} \
--parameters adminUsername=${{ vars.AZURE_ADMIN_USERNAME }} \
--parameters adminPassword=${{ secrets.AZURE_ADMIN_PASSWORD }} \
--parameters redisDeploymentOption=${{ vars.AZURE_REDIS_DEPLOYMENTOPTIONS }}
deploy:
runs-on: ubuntu-latest
needs: [preview]
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Sign in to Azure
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: azure/[email protected]
id: deployment
name: Deployment
with:
deploymentName: "GitHubAction-${{ github.run_number }}"
scope: subscription
region: ${{ vars.AZURE_LOCATION }}
template: ./infra//main.bicep
parameters: environmentName=${{ vars.AZURE_ENV_NAME }}
location=${{ vars.AZURE_LOCATION }}
fqdn=${{ vars.AZURE_FQDN }}
applicationName=${{ vars.AZURE_APPLICATION_NAME }}
mariaDBPassword=${{ secrets.AZURE_MARIADB_PASSWORD }}
adminUsername=${{ vars.AZURE_ADMIN_USERNAME }}
adminPassword=${{ secrets.AZURE_ADMIN_PASSWORD }}
redisDeploymentOption=${{ vars.AZURE_REDIS_DEPLOYMENTOPTIONS }}
failOnStdErr: false
# azd set up Federated Credential by default. You can remove this step if you are using Client Credentials
- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh

- name: Provision Infrastructure
run: azd up --no-prompt

- name: Tear Down Infrastructure
run: azd down --no-prompt --force --purge
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ In this application template, you'll learn how to and will be able to easily, qu
## Tech stack:

- Azure
- Azure-database-for-mariadb
- Azure-database-for-mysql flexible server
- Container Apps / Managed Environments
- Azure Storage
- Azure Key Vault
Expand Down
2 changes: 1 addition & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

name: app-template-wordpress
metadata:
template: [email protected].1-beta
template: [email protected].2
Loading

0 comments on commit 7fbeec0

Please sign in to comment.