simplify/merge workflow

This commit is contained in:
Chris Kruining 2024-11-18 14:25:15 +01:00
parent 516c744a72
commit 43b161b413
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
6 changed files with 29 additions and 52 deletions

View file

@ -2,8 +2,6 @@ name: Deploy App
on: on:
push: push:
paths-ignore:
- infrastructure/**
branches: branches:
- main - main
# pull_request: # pull_request:
@ -22,8 +20,7 @@ permissions:
jobs: jobs:
versionize: versionize:
name: Versionize name: Calculate next version
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
semver: ${{ steps.gitversion.outputs.SemVer }} semver: ${{ steps.gitversion.outputs.SemVer }}
@ -44,7 +41,6 @@ jobs:
build_and_publish: build_and_publish:
name: Build & Publish name: Build & Publish
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: versionize needs: versionize
steps: steps:
@ -67,12 +63,18 @@ jobs:
docker push ${{ secrets.ACR_LOGIN_SERVER }}/$IMAGE_NAME:${{needs.versionize.outputs.semver}} docker push ${{ secrets.ACR_LOGIN_SERVER }}/$IMAGE_NAME:${{needs.versionize.outputs.semver}}
docker push ${{ secrets.ACR_LOGIN_SERVER }}/$IMAGE_NAME:latest docker push ${{ secrets.ACR_LOGIN_SERVER }}/$IMAGE_NAME:latest
create_new_revision: deploy:
name: Create & Activate new revision name: Deploy app
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build_and_publish strategy:
matrix:
environment: [ 'prd' ]
steps: steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
infrastructure
- name: Az CLI login - name: Az CLI login
uses: azure/login@v2 uses: azure/login@v2
with: with:
@ -85,4 +87,9 @@ jobs:
with: with:
azcliversion: 2.66.0 azcliversion: 2.66.0
inlineScript: | inlineScript: |
az containerapp update --name calque-app --resource-group rg-euw-prd-calque --image ${{ secrets.ACR_LOGIN_SERVER }}/$IMAGE_NAME:${{needs.versionize.outputs.semver}} az deployment sub create \
--location westeurope \
--template-file infrastructure/main.bicep \
--parameters infrastructure/params/${{ matrix.environment }}.bicepparam \
--parameters version=${{ needs.versionize.outputs.semver }} \
--parameters registryUrl=${{ secrets.ACR_LOGIN_SERVER }}

View file

@ -1,35 +0,0 @@
name: Deploy infrastructure
on:
push:
paths-ignore:
- src/**
branches:
- main
permissions:
id-token: write
contents: read
jobs:
production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
infrastructure
- name: Az CLI login
uses: azure/login@v2
with:
client-id: ${{ secrets.CALQUE_PRD_CLIENT_ID }}
tenant-id: ${{ secrets.CALQUE_PRD_TENANT_ID }}
subscription-id: ${{ secrets.CALQUE_PRD_SUBSCRIPTION_ID }}
- name: Deploy bicep
uses: Azure/cli@v2
with:
azcliversion: 2.66.0
inlineScript: |
az deployment sub create --location westeurope --template-file infrastructure/main.bicep --parameters infrastructure/params/prod.bicepparam

View file

@ -3,10 +3,11 @@ import { Context } from 'types.bicep'
targetScope = 'resourceGroup' targetScope = 'resourceGroup'
param context Context param context Context
param registry resource'Microsoft.ContainerRegistry/registries@2023-07-01' param version string
@secure()
param registryUrl string
var appName = 'app' var appName = 'app'
var version = 'latest'
resource environment 'Microsoft.App/managedEnvironments@2024-03-01' = { resource environment 'Microsoft.App/managedEnvironments@2024-03-01' = {
name: 'cea-${context.locationAbbreviation}-${context.environment}-${context.projectName}' name: 'cea-${context.locationAbbreviation}-${context.environment}-${context.projectName}'
@ -65,7 +66,7 @@ resource app 'Microsoft.App/containerApps@2024-03-01' = {
registries: [ registries: [
{ {
identity: 'system' identity: 'system'
server: 'acreuwprdcalque.azurecr.io' server: registryUrl
} }
] ]
} }
@ -73,7 +74,7 @@ resource app 'Microsoft.App/containerApps@2024-03-01' = {
template: { template: {
containers: [ containers: [
{ {
image: 'acreuwprdcalque.azurecr.io/${context.projectName}-${appName}:${version}' image: '${registryUrl}/${context.projectName}-${appName}:${version}'
name: '${context.projectName}-${appName}' name: '${context.projectName}-${appName}'
resources: { resources: {
cpu: json('0.25') cpu: json('0.25')

View file

@ -6,6 +6,9 @@ param locationAbbreviation string
param location string param location string
param environment string param environment string
param projectName string param projectName string
param version string
@secure()
param registryUrl string
param deployedAt string = utcNow('yyyyMMdd') param deployedAt string = utcNow('yyyyMMdd')
var context = { var context = {
@ -42,6 +45,7 @@ module app 'app.bicep' = {
scope: calqueResourceGroup scope: calqueResourceGroup
params: { params: {
context: context context: context
registry: registry.outputs.registry version: version
registryUrl: registryUrl
} }
} }

View file

@ -4,3 +4,5 @@ param locationAbbreviation = 'euw'
param location = 'westeurope' param location = 'westeurope'
param environment = 'prd' param environment = 'prd'
param projectName = 'calque' param projectName = 'calque'
param version = 'latest'
param registryUrl = '__PLACEHOLDER__'

View file

@ -21,5 +21,3 @@ resource registry 'Microsoft.ContainerRegistry/registries@2023-07-01' = {
} }
} }
} }
output registry resource'Microsoft.ContainerRegistry/registries@2023-07-01' = registry