Prompt file imported from raykao/copilot-devsecops-rehearsal (
.github/prompts/scaffold-pipeline.prompt.md). Fill in{{workflow}}before use. Copyright stays with the author.
Extend {{workflow}} into the pipeline for infra/.
Read workflow instructions first. Then build:
Trigger on pull requests and pushes to main that touch infra/**, app/** or this workflow file.
- validate (every run):
terraform fmt -check,terraform init -backend=false,terraform validate. - plan (pull requests, after validate): run in the
planenvironment (it holds the Azure secrets and needs no approval), log in to Azure with OIDC, runterraform init, runterraform plan -out=tfplan, and post the plan as a pull request comment even when the plan fails. - apply (push to
mainonly, after validate): behind theproductionenvironment, re-runterraform plan -out=tfplanin the apply job (a PR plan file isn't available onmain), then apply that file. After the apply, deploy the app: zip theapp/directory itself (zip -r app.zip app, sonode app/server.jsresolves) and push it withaz webapp deploy --type zip, using theapi_app_nameandresource_group_nameoutputs. - smoke (after apply):
curl --failthe/api/healthendpoint of theapi_hostnameoutput, retrying for up to two minutes. - rollback: a
workflow_dispatchinputrollback_refthat checks out that commit and re-applies it behind the sameproductionenvironment.
State is local to each run (no remote backend), so use plain terraform init in the plan and apply jobs. Azure IDs come from the environment secrets AZURE_CLIENT_ID, AZURE_TENANT_ID and AZURE_SUBSCRIPTION_ID.
When you're done, check your own work against the instructions file and list any guardrail you couldn't meet. Don't run anything that touches Azure.
