Skip to content

Commit

Permalink
Merge branch 'main' into feat/restore-dialog-action
Browse files Browse the repository at this point in the history
  • Loading branch information
oskogstad authored Feb 6, 2025
2 parents f4ce981 + eb8f04d commit e01e4e7
Show file tree
Hide file tree
Showing 50 changed files with 139 additions and 1,566 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/ci-cd-prod-dry-run.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: CI/CD Production

# Runs a dry-run deployment of production whenever a new release is created
name: CI/CD Production Dry Run
run-name: CI/CD Production Dry Run ${{ github.event.client_payload.version && format('({0})', github.event.client_payload.version) || '' }}

on:
workflow_dispatch:
repository_dispatch:
types: [release_created]

Expand All @@ -27,14 +26,10 @@ jobs:
infra_base_sha: ${{ needs.get-versions-from-github.outputs.infra_version_sha }}
apps_base_sha: ${{ needs.get-versions-from-github.outputs.apps_version_sha }}

get-current-version:
name: Get current version
uses: ./.github/workflows/workflow-get-current-version.yml

dry-run-deploy-infra:
name: Dry run deploy infra to prod
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
needs: [get-current-version, check-for-changes]
if: ${{ needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
needs: [check-for-changes]
uses: ./.github/workflows/workflow-deploy-infra.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -47,15 +42,14 @@ jobs:
with:
environment: prod
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
version: ${{ github.event.client_payload.version }}
dryRun: true
ref: "refs/tags/v${{ github.event.client_payload.version }}"

dry-run-deploy-apps:
name: Dry run deploy apps to prod
needs:
[get-current-version, check-for-changes, dry-run-deploy-infra]
# we want deployment of apps to be dependent on deployment of infrastructure, but if infrastructure is skipped, we still want to dry-run deploy the apps
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true') }}
needs: [check-for-changes, dry-run-deploy-infra]
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
uses: ./.github/workflows/workflow-deploy-apps.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -71,10 +65,11 @@ jobs:
with:
environment: prod
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
version: ${{ github.event.client_payload.version }}
dryRun: true
runMigration: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}

runMigration: ${{ needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}
ref: "refs/tags/v${{ github.event.client_payload.version }}"

send-slack-message-on-failure:
name: Send Slack message on failure
needs: [dry-run-deploy-infra, dry-run-deploy-apps]
Expand Down
48 changes: 33 additions & 15 deletions .github/workflows/ci-cd-prod.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
name: CI/CD Production
# Deploys the specified version to production
name: CI/CD Production
run-name: CI/CD Production ${{ inputs.version && format('({0})', inputs.version) || '' }}

on:
workflow_dispatch:

inputs:
version:
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
group: ${{ github.workflow }}

jobs:
check-if-version-exists:
name: Check if version exists
runs-on: ubuntu-latest
steps:
- name: Check if tag exists
run: |
if ! gh api repos/${{ github.repository }}/git/refs/tags/${{ inputs.version }} &>/dev/null; then
echo "::error::Version ${{ inputs.version }} does not exist as a tag"
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

get-versions-from-github:
name: Get Latest Deployed Version Info from GitHub
needs: [check-if-version-exists]
uses: ./.github/workflows/workflow-get-latest-deployed-version-info-from-github.yml
with:
environment: prod
Expand All @@ -23,14 +43,10 @@ jobs:
infra_base_sha: ${{ needs.get-versions-from-github.outputs.infra_version_sha }}
apps_base_sha: ${{ needs.get-versions-from-github.outputs.apps_version_sha }}

get-current-version:
name: Get current version
uses: ./.github/workflows/workflow-get-current-version.yml

deploy-infra:
name: Deploy infra to prod
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
needs: [get-current-version, check-for-changes]
needs: [check-for-changes]
uses: ./.github/workflows/workflow-deploy-infra.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -43,24 +59,25 @@ jobs:
with:
environment: prod
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
version: ${{ inputs.version }}
ref: "refs/tags/v${{ inputs.version }}"

store-infra-version:
name: Store Latest Deployed Infra Version as GitHub Variable
needs: [deploy-infra, get-current-version]
needs: [deploy-infra]
if: ${{ needs.deploy-infra.result == 'success' }}
uses: ./.github/workflows/workflow-store-github-env-variable.yml
with:
variable_name: LATEST_DEPLOYED_INFRA_VERSION
variable_value: ${{ needs.get-current-version.outputs.version }}
variable_value: ${{ inputs.version }}
environment: prod
secrets:
GH_TOKEN: ${{ secrets.RELEASE_VERSION_STORAGE_PAT }}

deploy-apps:
name: Deploy apps to prod
needs:
[get-current-version, check-for-changes]
[check-for-changes]
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
uses: ./.github/workflows/workflow-deploy-apps.yml
secrets:
Expand All @@ -77,17 +94,18 @@ jobs:
with:
environment: prod
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
version: ${{ inputs.version }}
runMigration: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}
ref: "refs/tags/v${{ inputs.version }}"

store-apps-version:
name: Store Latest Deployed Apps Version as GitHub Variable
needs: [deploy-apps, get-current-version]
needs: [deploy-apps]
if: ${{ always() && !failure() && (github.event_name == 'workflow_dispatch' || needs.deploy-apps.outputs.deployment_executed == 'true') }}
uses: ./.github/workflows/workflow-store-github-env-variable.yml
with:
variable_name: LATEST_DEPLOYED_APPS_VERSION
variable_value: ${{ needs.get-current-version.outputs.version }}
variable_value: ${{ inputs.version }}
environment: prod
secrets:
GH_TOKEN: ${{ secrets.RELEASE_VERSION_STORAGE_PAT }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci-cd-pull-request-release-please.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CI/CD Pull Request Release Please

# Run dry-runs of staging deployment on release PRs
name: CI/CD Pull Request Release Please
on:
pull_request:
branches: [main]
Expand All @@ -15,10 +15,12 @@ jobs:

get-current-version:
name: Get current version
needs: [verify-release-please-branch]
uses: ./.github/workflows/workflow-get-current-version.yml

check-for-changes:
name: Check for changes
needs: [verify-release-please-branch]
uses: ./.github/workflows/workflow-check-for-changes.yml

generate-git-short-sha:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cd-pull-request-title.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Checks the title of a PR to ensure it follows the correct format
name: "PR Title Checker"
on:
pull_request_target:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-cd-release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# 2.3. Triggers staging and yt01 deployment via repository dispatch

name: CI/CD Release Please

on:
push:
branches: [main]
Expand Down
46 changes: 22 additions & 24 deletions .github/workflows/ci-cd-staging.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: CI/CD Staging

# Deploys the created release to staging
name: CI/CD Staging
run-name: CI/CD Staging ${{ github.event.client_payload.version && format('({0})', github.event.client_payload.version) || '' }}

on:
workflow_dispatch:
repository_dispatch:
types: [release_created]

Expand All @@ -27,14 +26,10 @@ jobs:
infra_base_sha: ${{ needs.get-versions-from-github.outputs.infra_version_sha }}
apps_base_sha: ${{ needs.get-versions-from-github.outputs.apps_version_sha }}

get-current-version:
name: Get current version
uses: ./.github/workflows/workflow-get-current-version.yml

deploy-infra:
name: Deploy infra to staging
if: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
needs: [get-current-version, check-for-changes]
if: ${{ needs.check-for-changes.outputs.hasInfraChanges == 'true' }}
needs: [check-for-changes]
uses: ./.github/workflows/workflow-deploy-infra.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -47,25 +42,25 @@ jobs:
with:
environment: staging
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
version: ${{ github.event.client_payload.version }}
ref: "refs/tags/v${{ github.event.client_payload.version }}"

store-infra-version:
name: Store Latest Deployed Infra Version as GitHub Variable
needs: [deploy-infra, get-current-version]
needs: [deploy-infra]
if: ${{ needs.deploy-infra.result == 'success' }}
uses: ./.github/workflows/workflow-store-github-env-variable.yml
with:
variable_name: LATEST_DEPLOYED_INFRA_VERSION
variable_value: ${{ needs.get-current-version.outputs.version }}
variable_value: ${{ github.event.client_payload.version }}
environment: staging
secrets:
GH_TOKEN: ${{ secrets.RELEASE_VERSION_STORAGE_PAT }}

deploy-apps:
name: Deploy apps to staging
needs:
[get-current-version, check-for-changes, deploy-infra]
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true') }}
needs: [check-for-changes, deploy-infra]
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
uses: ./.github/workflows/workflow-deploy-apps.yml
secrets:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
Expand All @@ -80,35 +75,37 @@ jobs:
with:
environment: staging
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
runMigration: ${{ github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}
version: ${{ github.event.client_payload.version }}
runMigration: ${{ needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}
ref: "refs/tags/v${{ github.event.client_payload.version }}"

store-apps-version:
name: Store Latest Deployed Apps Version as GitHub Variable
needs: [deploy-apps, get-current-version]
if: ${{ always() && !failure() && (github.event_name == 'workflow_dispatch' || needs.deploy-apps.outputs.deployment_executed == 'true') }}
needs: [deploy-apps]
if: ${{ always() && !failure() && needs.deploy-apps.outputs.deployment_executed == 'true' }}
uses: ./.github/workflows/workflow-store-github-env-variable.yml
with:
variable_name: LATEST_DEPLOYED_APPS_VERSION
variable_value: ${{ needs.get-current-version.outputs.version }}
variable_value: ${{ github.event.client_payload.version }}
environment: staging
secrets:
GH_TOKEN: ${{ secrets.RELEASE_VERSION_STORAGE_PAT }}

publish-schema-npm:
name: Publish schema npm package
needs: [check-for-changes, get-current-version, deploy-apps]
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasSchemaChanges == 'true') }}
needs: [check-for-changes, deploy-apps]
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasSchemaChanges == 'true' }}
uses: ./.github/workflows/workflow-publish-schema.yml
with:
version: ${{ needs.get-current-version.outputs.version }}
version: ${{ github.event.client_payload.version }}
ref: "refs/tags/v${{ github.event.client_payload.version }}"
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

run-e2e-tests:
name: "Run K6 functional end-to-end tests"
# we want the end-to-end tests to be dependent on deployment of infrastructure and apps, but if infrastructure is skipped, we still want to run the tests
if: ${{ always() && !failure() && !cancelled() && (github.event_name == 'workflow_dispatch' || needs.check-for-changes.outputs.hasBackendChanges == 'true') }}
if: ${{ always() && !failure() && !cancelled() && needs.check-for-changes.outputs.hasBackendChanges == 'true' }}
needs: [deploy-apps, check-for-changes]
uses: ./.github/workflows/workflow-run-k6-tests.yml
secrets:
Expand All @@ -118,6 +115,7 @@ jobs:
environment: staging
apiVersion: v1
testSuitePath: tests/k6/suites/all-single-pass.js
ref: "refs/tags/v${{ github.event.client_payload.version }}"
permissions:
checks: write
pull-requests: write
Expand Down
Loading

0 comments on commit e01e4e7

Please sign in to comment.