-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (92 loc) · 4.03 KB
/
ci-cd-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Infra apply test
on:
workflow_dispatch:
inputs:
initialDeploy:
type: boolean
description: Initial deploy
default: false
push:
branches: [main]
paths-ignore:
- "Test/**" # ignore changes to tests
env:
name: broker
deployment_environment: test
permissions:
contents: write
pull-requests: write
packages: write
id-token: write
jobs:
generate-git-short-sha:
name: Generate git short sha
uses: ./.github/workflows/action-generate-git-short-sha.yml
get-current-version:
name: Get current version
uses: ./.github/workflows/action-get-current-version.yml
check-for-changes:
name: Check for changes
uses: ./.github/workflows/action-check-for-changes.yml
test:
name: Test application
uses: ./.github/workflows/action-test-application.yml
needs: [check-for-changes]
if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}
publish:
name: Build and publish docker images
uses: ./.github/workflows/action-build-and-push.yml
needs: [get-current-version, generate-git-short-sha, check-for-changes, test]
if: ${{ inputs.initialDeploy || needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
with:
dockerImageBaseName: ghcr.io/altinn/altinn-broker
version: ${{ needs.get-current-version.outputs.version }}-${{ needs.generate-git-short-sha.outputs.gitShortSha }}
deploy-infra:
name: Deploy infrastructure
if: ${{ inputs.initialDeploy || needs.check-for-changes.outputs.hasAzureChanges == 'true' }}
needs: [check-for-changes, get-current-version, test]
uses: ./.github/workflows/action-deploy-infra.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_OIDC_TEST_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_OIDC_TEST_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_OIDC_TEST_SUBSCRIPTION_ID }}
AZURE_OBJECT_ID: ${{ secrets.AZURE_TEST_PRINCIPAL_ID}}
AZURE_TEST_ACCESS_CLIENT_ID : ${{ secrets.AZURE_TEST_ACCESS_CLIENT_ID }}
AZURE_NAME_PREFIX: ${{ secrets.AZURE_TEST_NAME_PREFIX }}
AZURE_SOURCE_KEY_VAULT_NAME: ${{ secrets.AZURE_SOURCE_TEST_KEY_VAULT_NAME }}
AZURE_MIGRATION_STORAGE_ACCOUNT_NAME: ${{ secrets.AZURE_TEST_MIGRATION_STORAGE_ACCOUNT_NAME }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_TEST_CLIENT_SECRET }}
MASKINPORTEN_JWK: ${{ secrets.MASKINPORTEN_JWK }}
MASKINPORTEN_CLIENT_ID: ${{ secrets.MASKINPORTEN_CLIENT_ID }}
PLATFORM_SUBSCRIPTION_KEY: ${{ secrets.PLATFORM_SUBSCRIPTION_KEY }}
with:
region: norwayeast
environment: test
version: ${{ needs.get-current-version.outputs.version }}
ref: ${{ github.ref }}
deploy-app:
name: Deploy app to test
needs:
[
get-current-version,
check-for-changes,
generate-git-short-sha,
publish,
deploy-infra, # we want deployment of app to be dependent on deployment of infrastructure, but if infrastructure is skipped, we still want to deploy the app
test
]
if: ${{ (inputs.initialDeploy || needs.check-for-changes.outputs.hasBackendChanges == 'true') && always() && !failure() && !cancelled() }}
uses: ./.github/workflows/action-deploy-app.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_OIDC_TEST_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_OIDC_TEST_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_OIDC_TEST_SUBSCRIPTION_ID }}
AZURE_ENVIRONMENT_KEY_VAULT_NAME: ${{ secrets.AZURE_SOURCE_TEST_KEY_VAULT_NAME }}
AZURE_NAME_PREFIX: ${{ secrets.AZURE_TEST_NAME_PREFIX }}
AZURE_MIGRATION_STORAGE_ACCOUNT_NAME: ${{ secrets.AZURE_TEST_MIGRATION_STORAGE_ACCOUNT_NAME }}
with:
environment: test
region: norwayeast
ref: ${{ github.ref }}
version: ${{ needs.get-current-version.outputs.version }}-${{ needs.generate-git-short-sha.outputs.gitShortSha }}
migrate: ${{ needs.check-for-changes.outputs.hasMigrationChanges == 'true' || github.event.inputs.initialDeploy }}