Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a4c7a62
OICD test
Invvard Jun 16, 2024
ab48a0a
Add wf dispatch
Invvard Jun 16, 2024
770abfe
Split job
Invvard Jun 16, 2024
69be7f0
Permissions
Invvard Jun 16, 2024
7c81851
Write permission
Invvard Jun 16, 2024
45e47de
Add terraform scripts
Invvard Jun 16, 2024
d12eacd
Fix working directory
Invvard Jun 16, 2024
062634c
Add Terraform plan
Invvard Jun 16, 2024
c3920ae
Publish plan to summary
Invvard Jun 16, 2024
3455b03
Fix tfplan upload
Invvard Jun 16, 2024
f5846c2
Split workflow
Invvard Jun 16, 2024
4683da0
Pass secrets to sub workflow
Invvard Jun 16, 2024
d15168c
Simplify summary
Invvard Jun 16, 2024
90ca9c9
Remove delimiter
Invvard Jun 16, 2024
c272e4f
Add TF Apply
Invvard Jun 16, 2024
4048e0f
Add working directory
Invvard Jun 16, 2024
100ac30
Fix working directory
Invvard Jun 16, 2024
84b37cf
Fix variable ref
Invvard Jun 16, 2024
5d9466c
Inherit secrets
Invvard Jun 17, 2024
90e5d57
Fix variable ref
Invvard Jun 17, 2024
75e9b5f
Download plan into working directory
Invvard Jun 17, 2024
9a844f7
Refactor TF commands
Invvard Jun 17, 2024
82424bf
Fix switch case
Invvard Jun 17, 2024
1e745bc
Typo
Invvard Jun 17, 2024
ef20fe5
Fix conditions
Invvard Jun 17, 2024
28b284b
Add App Service resources
Invvard Jun 17, 2024
d376622
Replace obsolete resource
Invvard Jun 17, 2024
fd1b803
Update app resources
Invvard Jun 17, 2024
b7a576e
Disable always_on flag
Invvard Jun 17, 2024
d010077
Add TF Destroy
Invvard Jun 17, 2024
c25c2ec
Add provisionning to sample deploy
Invvard Jun 17, 2024
a480275
Split sample app deployment
Invvard Jun 18, 2024
e03aa9f
Fix runner reference
Invvard Jun 18, 2024
47c649f
App name in TF Variable
Invvard Jun 19, 2024
15248e5
Add TF Destroy
Invvard Jun 19, 2024
b31fdf4
Limit workflow trigger to develop branch with specific paths
Invvard Jun 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/samples-infra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "azurerm_resource_group" "rg" {
name = "rg-iftttnet-sample-apps"
location = "canadacentral"
tags = {
environment = "dev",
owner = "invvard"
}
}

resource "azurerm_service_plan" "asp_iftttnet_sample_apps" {
name = "asp-iftttnet-sample-apps"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
os_type = "Linux"
sku_name = "F1"
}

resource "azurerm_linux_web_app" "lwa_iftttnet_sample_trigger" {
name = var.web_app_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
service_plan_id = azurerm_service_plan.asp_iftttnet_sample_apps.id

https_only = true

site_config {
always_on = false
application_stack {
dotnet_version = "8.0"
}
}
}
3 changes: 3 additions & 0 deletions .github/samples-infra/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "web_app_name" {
type = string
}
21 changes: 21 additions & 0 deletions .github/samples-infra/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
terraform {
backend "azurerm" {
resource_group_name = "rg-iftttnet-samples-backend"
storage_account_name = "saiftttnettfbackend"
container_name = "tfstates"
key = "terraform.tfstate"
use_oidc = true
}

required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.108.0"
}
}
}

provider "azurerm" {
features {}
use_oidc = true
}
67 changes: 0 additions & 67 deletions .github/workflows/dotnet-deploy-sample.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/samples-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and deploy sample apps

on:
push:
branches:
- develop
paths:
- "samples/**"
- ".github/infra/**"
workflow_dispatch:

concurrency:
group: samples-${{ github.workflow }}-${{ github.actor_id }}
cancel-in-progress: true

jobs:
terraform-plan:
name: Terraform Plan
uses: ./.github/workflows/wf-tf-plan.yaml
permissions:
id-token: write
with:
tfvarWebAppName: ${{ vars.SAMPLE_APP_TRIGGER_NAME }}
secrets: inherit

terraform-apply:
name: Terraform Apply
uses: ./.github/workflows/wf-tf-apply.yaml
needs: terraform-plan
permissions:
id-token: write
secrets: inherit

build-trigger:
name: Build & Publish Trigger App
uses: ./.github/workflows/wf-samples-build.yaml
with:
appName: ${{ vars.SAMPLE_APP_TRIGGER_NAME }}

deploy-trigger:
name: Deploy Trigger App
uses: ./.github/workflows/wf-samples-deploy.yaml
needs: [build-trigger, terraform-apply]
permissions:
id-token: write
with:
appName: ${{ vars.SAMPLE_APP_TRIGGER_NAME }}
secrets: inherit
38 changes: 38 additions & 0 deletions .github/workflows/samples_destroy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: samples_destroy
run-name: Destroy sample apps

on:
workflow_dispatch:

jobs:
tf-destroy:
name: Destroy sample apps
runs-on: ubuntu-latest
environment: development
env:
ARM_CLIENT_ID: "${{ secrets.AZURE_CLIENT_ID }}"
ARM_SUBSCRIPTION_ID: "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
ARM_TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
WORKING_DIRECTORY: .github/samples-infra
TF_VAR_WEB_APP_NAME: ${{ vars.SAMPLE_APP_TRIGGER_NAME }}
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}

steps:
- name: Checkout Terraform
uses: actions/checkout@v4
with:
sparse-checkout: ${{ env.WORKING_DIRECTORY }}
sparse-checkout-cone-mode: false

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3

- name: Terraform Init
run: terraform init

- name: Terraform Destroy ${{ env.TF_VAR_WEB_APP_NAME }}
env:
TF_VAR_web_app_name: ${{ env.TF_VAR_WEB_APP_NAME }}
run: terraform apply -destroy -auto-approve
44 changes: 44 additions & 0 deletions .github/workflows/wf-samples-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: wf-samples-build
run-name: Build sample app

on:
workflow_call:
inputs:
appName:
description: "App name"
type: string
default: "sample-app"

jobs:
build:
name: Build & Publish ${{ inputs.appName }} app
runs-on: ubuntu-latest
env:
APP_NAME: ${{ inputs.appName }}
PUBLISH_DIR: ${{ github.workspace }}/publish

steps:
- name: Checkout Samples directory
uses: actions/checkout@v4
with:
sparse-checkout: samples
sparse-checkout-cone-mode: false

- name: Set up .NET Core
uses: actions/setup-dotnet@v4.0.0
with:
dotnet-version: 8.0.x
dotnet-quality: ga

- name: Build & Publish ${{ env.APP_NAME }}
run: |
dotnet restore
dotnet build --configuration Release
dotnet publish --no-build --property:PublishDir=${{ env.PUBLISH_DIR }}/
working-directory: samples

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: ${{ env.APP_NAME }}
path: ${{ env.PUBLISH_DIR }}
38 changes: 38 additions & 0 deletions .github/workflows/wf-samples-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: wf-samples-deploy
run-name: Deploy sample app

on:
workflow_call:
inputs:
appName:
description: "App name"
type: string
default: "sample-app"

jobs:
deploy:
name: Deploy ${{ inputs.appName }} app
runs-on: ubuntu-latest
environment: development
env:
APP_NAME: ${{ inputs.appName }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: ${{ env.APP_NAME }}

- 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 ${{ env.APP_NAME }} to Azure
uses: azure/webapps-deploy@v3
with:
app-name: ${{ env.APP_NAME }}
slot-name: "production"
package: .
63 changes: 37 additions & 26 deletions .github/workflows/wf-tester.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,45 @@ name: Workflow Tester
run-name: Workflow Tester

on:
workflow_dispatch:
inputs:
tfAction:
description: "Terraform action to run"
type: choice
options:
- plan
- apply
- destroy
default: plan
push:
tags:
- '[0-1].[0-9]+.[0-9]+' # '0.1.1', '0.14.23'
- '[0-1].[0-9]+.[0-9]+-alpha[0-9]?[0-9]?' # '0.14.23-alpha', '1.14.23-alpha1', '1.14.23-alpha23'
- '[0-1].[0-9]+.[0-9]+-beta[0-9]?[0-9]?' # '0.14.23-beta', '1.14.23-beta1', '1.14.23-beta23'
- '[0-1].[0-9]+.[0-9]+-rc[0-9]?[0-9]?' # '0.14.23-rc', '1.14.23-rc1', '1.14.23-rc23'
branches:
- disabled-samples/*

jobs:
test_workflows:
name: Test Workflows
runs-on: ubuntu-latest

steps:
- name: Output tag name
run: |
echo "Tag name: ${{ github.ref_name }}"
env:
TFPLAN_FILE_NAME: "tfplan"

- name: Checkout Repository
uses: actions/checkout@v4
with:
sparse-checkout: src

- name: Create packages directory
run: mkdir -p packages
jobs:
terraform-plan:
name: Terraform Plan
uses: ./.github/workflows/wf-tf-plan.yaml
if: ( github.event_name == 'push' || github.event.inputs.tfAction == 'plan' )
permissions:
id-token: write
secrets: inherit

- name: Define optional Package Version
id: optional_parameter
run: echo "packVersion=${{ contains(github.ref_name, 'alpha') && format('-p:PackageVersion=''{0}''', github.ref_name) || '' }}" >> $GITHUB_OUTPUT
terraform-apply:
name: Terraform Apply
uses: ./.github/workflows/wf-tf-apply.yaml
needs: terraform-plan
if: ( github.event_name == 'push' || github.event.inputs.tfAction == 'apply') && needs.terraform-plan.outputs.tfplanExitCode == 2
permissions:
id-token: write
secrets: inherit

- name: Pack
run: dotnet pack $GITHUB_WORKSPACE/src/InvvardDev.Ifttt.csproj ${{ steps.optional_parameter.outputs.packVersion }}
terraform-destroy:
name: Terraform Destroy
uses: ./.github/workflows/wf-tf-destroy.yaml
if: ( github.event_name == 'workflow_dispatch' && github.event.inputs.tfAction == 'destroy' )
permissions:
id-token: write
secrets: inherit
Loading