From 5ce6c939a716efc86b20996008f7235b1f634cd6 Mon Sep 17 00:00:00 2001 From: Lyon Till <158992+ljtill@users.noreply.github.com> Date: Mon, 30 Sep 2024 17:36:28 +0200 Subject: [PATCH] docs: add workflow examples (#18) --- README.md | 7 ++- examples/DEPLOYMENT.md | 99 +++++++++++++++++++++++++++++++ examples/STACKS.md | 131 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 235 insertions(+), 2 deletions(-) create mode 100644 examples/DEPLOYMENT.md create mode 100644 examples/STACKS.md diff --git a/README.md b/README.md index 3db89c0..5c74343 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Deployment scope: subscription subscription-id: 00000000-0000-0000-0000-000000000000 template-file: ./main.bicep - parameters: ./main.bicepparam + parameters-file: ./main.bicepparam ``` Deployment Stack @@ -53,10 +53,13 @@ Deployment Stack subscription-id: 00000000-0000-0000-0000-000000000000 template-file: ./main.bicep parameters-file: ./main.bicepparam - action-on-unmanage: deleteAll + action-on-unmanage-resources: delete + action-on-unmanage-resourcegroups: delete deny-settings-mode: denyWriteAndDelete ``` +For end-to-end workflow examples, please see [Deployment](./examples/DEPLOYMENT.md) & [Deployment Stacks](./examples/STACKS.md). + ## Dependencies - [Login](https://github.com/azure/login): This action is used to authenticate diff --git a/examples/DEPLOYMENT.md b/examples/DEPLOYMENT.md new file mode 100644 index 0000000..142bff0 --- /dev/null +++ b/examples/DEPLOYMENT.md @@ -0,0 +1,99 @@ +# Deployment + +**Create & Update** + +```yaml +name: Deployment (Create) + +on: + push: + branches: + - main + +permissions: + contents: read + id-token: write + +jobs: + deployment: + name: "Deployment" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Create + uses: azure/deploy@v1 + with: + operation: deployment + type: create + name: Development + location: westus2 + scope: subscription + subscription-id: 00000000-0000-0000-0000-000000000000 + template-file: ./main.bicep + parameters-file: ./main.bicepparameters.json +``` + +**Validate & What-If** + +```yaml +name: Deployment (Validate) + +on: + pull_request: + branches: + - main + +permissions: + contents: read + id-token: write + +jobs: + deployment: + name: "Validate" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Validate + uses: azure/deploy@v1 + with: + operation: deployment + type: validate + name: Development + location: westus2 + scope: subscription + subscription-id: 00000000-0000-0000-0000-000000000000 + template-file: ./main.bicep + parameters-file: ./main.bicepparam + + - name: What-If + uses: azure/deploy@v1 + with: + operation: deployment + type: whatIf + name: Development + location: westus2 + scope: subscription + subscription-id: 00000000-0000-0000-0000-000000000000 + template-file: ./main.bicep + parameters-file: ./main.bicepparam +``` diff --git a/examples/STACKS.md b/examples/STACKS.md new file mode 100644 index 0000000..9a06c2b --- /dev/null +++ b/examples/STACKS.md @@ -0,0 +1,131 @@ +# Deployment Stacks + +**Create** + +```yaml +name: Stacks (Create) + +on: + push: + branches: + - main + +permissions: + contents: read + id-token: write + +jobs: + deployment: + name: "Stacks" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Create + uses: azure/deploy@v1 + with: + operation: deploymentStack + type: create + name: Development + location: westus2 + scope: subscription + subscription-id: 00000000-0000-0000-0000-000000000000 + template-file: ./main.bicep + parameters-file: ./main.bicepparameters.json + action-on-unmanage-resources: delete + action-on-unmanage-resourcegroups: delete + deny-settings-mode: denyWriteAndDelete + description: "Development Environment" +``` + +**Validate** + +```yaml +name: Stacks (Validate) + +on: + pull_request: + branches: + - main + +permissions: + contents: read + id-token: write + +jobs: + deployment: + name: "Stacks" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Validate + uses: azure/deploy@v1 + with: + operation: deploymentStack + type: validate + name: Development + location: westus2 + scope: subscription + subscription-id: 00000000-0000-0000-0000-000000000000 + template-file: ./main.bicep + parameters-file: ./main.bicepparameters.json +``` + +**Delete** + +```yaml +name: Stacks (Delete) + +on: workflow_dispatch + +permissions: + contents: read + id-token: write + +jobs: + deployment: + name: "Stacks" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login + 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 + uses: azure/deploy@v1 + with: + operation: deploymentStack + type: delete + name: Development + location: westus2 + scope: subscription + subscription-id: 00000000-0000-0000-0000-000000000000 + template-file: ./main.bicep + parameters-file: ./main.bicepparameters.json +```