Skip to content

Commit

Permalink
ci: only run if migrations are changed (#669)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description

- Only run migrations if relevant files are changed
- Run the deployment of apps regardless of if migration was run

<!--- Describe your changes in detail -->

## Related Issue(s)

- #{issue number}

## Verification

- [ ] **Your** code builds clean without any errors or warnings
- [ ] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)
  • Loading branch information
arealmaas authored Apr 23, 2024
1 parent c738797 commit 7cd80dc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/action-check-for-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ on:
hasSlackNotifierChanges:
description: "Slack Notifier function related files changed"
value: ${{ jobs.check-for-changes.outputs.hasSlackNotifierChanges }}
hasMigrationChanges:
description: "Migration related files changed"
value: ${{ jobs.check-for-changes.outputs.hasMigrationChanges }}
jobs:
check-for-changes:
name: Filter
Expand All @@ -20,7 +23,7 @@ jobs:
hasBackendChanges: ${{ steps.filter.outputs.backend_any_changed == 'true' }}
hasAzureChanges: ${{ steps.filter.outputs.azure_any_changed == 'true' }}
hasSlackNotifierChanges: ${{ steps.filter.outputs.slackNotifier_any_changed == 'true'}}

hasMigrationChanges: ${{ steps.filter.outputs.migration_any_changed == 'true'}}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -43,3 +46,5 @@ jobs:
slackNotifier:
- '.github/**/*'
- 'src/Digdir.Tool.Dialogporten.SlackNotifier/**/*'
migration:
- 'src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/**/*'
8 changes: 8 additions & 0 deletions .github/workflows/action-deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ on:
description: "Current version to use as tag"
required: true
type: string
runMigration:
description: "If true, the migration job will be run."
required: false
type: boolean
default: false
concurrency:
# Existing runs are cancelled if someone repeatedly commits to their own Pull Request (PR). However, it does not stop others' dry runs or actual deployments from the main branch.
# Also, the cancellation does not occur on merges to the main branch. Therefore, if multiple merges to main are performed simultaneously, they will just be queued up.
Expand All @@ -47,6 +52,7 @@ jobs:
deploy-migration-job:
name: Deploy migration job to ${{ inputs.environment }}
runs-on: ubuntu-latest
if: ${{ inputs.runMigration }}
environment: ${{inputs.environment}}
permissions:
id-token: write
Expand Down Expand Up @@ -108,6 +114,8 @@ jobs:
deploy-apps:
name: Deploy ${{ matrix.name }} to ${{ inputs.environment }}
runs-on: ubuntu-latest
# Should run even though the migration job was skipped
if: ${{ always() && !failure() && !cancelled() }}
needs: deploy-migration-job
strategy:
fail-fast: true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
environment: test
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}-${{ needs.generate-git-short-sha.outputs.gitShortSha }}
runMigration: ${{ needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}

deploy-slack-notifier-test:
name: Deploy slack notifier (test)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-cd-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
environment: staging
region: norwayeast
version: ${{ needs.get-current-version.outputs.version }}
runMigration: ${{ needs.check-for-changes.outputs.hasMigrationChanges == 'true' }}

run-e2e-tests:
name: "Run K6 functional end-to-end tests"
Expand Down

0 comments on commit 7cd80dc

Please sign in to comment.