Skip to content

test ci/cd script

test ci/cd script #24

Workflow file for this run

name: CI/CD
on:
push:
branches: [ main, bug/fix-infra-change-check ]
paths-ignore:
- "Test/**" # ignore changes to tests
jobs:
prepare-deployment:
name: Prepare deployment
runs-on: ubuntu-latest
outputs:
hasAzureChanges: ${{ steps.check-for-changes.outputs.hasAzureChanges }}
hasBackendChanges: ${{ steps.check-for-changes.outputs.hasBackendChanges }}
hasMigrationChanges: ${{ steps.check-for-changes.outputs.hasMigrationChanges }}
imageTag: ${{ steps.get-version.outputs.imageTag}}
steps:
- uses: actions/checkout@v4
- name: "Check for changes"
id: check-for-changes
uses: ./.github/actions/check-for-changes
- name: "Inform about infrastructure skip"
if: ${{ steps.check-for-changes.outputs.hasAzureChanges != 'true' }}
run: echo "::warning file=.github/workflows/ci-cd.yaml,line=1,col=1::Infrastructure-as-code did not change. Infrastructure update will be skipped."
- name: "Inform about publish skip"
if: ${{ steps.check-for-changes.outputs.hasBackendChanges != 'true' }}
run: echo "::warning file=.github/workflows/ci-cd.yaml,line=1,col=1::Code not changed. Will not publish and release new version."
- name: "Inform about database migration skip"
if: ${{ steps.check-for-changes.outputs.hasMigrationChanges != 'true' }}
run: echo "::warning file=.github/workflows/ci-cd.yaml,line=1,col=1::Migrations did not change. No migration will run."
- name: Get version
id: get-version
uses: ./.github/actions/get-current-version
test:
name: QA
uses: ./.github/workflows/test-application.yml
needs: [prepare-deployment]
if: ${{ needs.prepare-deployment.outputs.hasBackendChanges == 'true' || needs.prepare-deployment.outputs.hasMigrationChanges == 'true' }}
publish:
name: Publish
runs-on: ubuntu-latest
needs: [prepare-deployment]
if: ${{ needs.prepare-deployment.outputs.hasBackendChanges == 'true' }}
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: "Publish image"
uses: ./.github/actions/publish-image
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dockerImageBaseName: ghcr.io/altinn/altinn-correspondence
deploy-test:
name: Internal test
uses: ./.github/workflows/deploy-to-environment.yml
if: always() && !failure() && !cancelled()
needs: [
publish,
prepare-deployment
]
permissions:
id-token: write
contents: read
secrets: inherit
with:
environment: test
hasAzureChanges: ${{ needs.prepare-deployment.outputs.hasAzureChanges }}
hasBackendChanges: ${{ needs.prepare-deployment.outputs.hasBackendChanges }}
hasMigrationChanges: ${{ needs.prepare-deployment.outputs.hasMigrationChanges }}
imageTag: ${{ needs.prepare-deployment.outputs.imageTag }}
# deploy-staging:
# name: Internal staging
# uses: ./.github/workflows/deploy-to-environment.yml
# if: always() && !failure() && !cancelled()
# needs: [
# check-for-changes,
# deploy-test
# ]
# permissions:
# id-token: write
# contents: read
# secrets: inherit
# with:
# environment: staging
# hasAzureChanges: ${{ needs.check-for-changes.outputs.hasAzureChanges }}
# hasBackendChanges: ${{ needs.check-for-changes.outputs.hasBackendChanges }}
# hasMigrationChanges: ${{ needs.check-for-changes.outputs.hasMigrationChanges }}
#
# deploy-production:
# name: Production
# needs: [
# deploy-staging,
# check-for-changes
# ]
# uses: ./.github/workflows/deploy-to-environment.yml
# if: (!failure() && !cancelled())
# permissions:
# id-token: write
# contents: read
# secrets: inherit
# with:
# environment: production
# hasAzureChanges: ${{ needs.check-for-changes.outputs.hasAzureChanges }}
# hasBackendChanges: ${{ needs.check-for-changes.outputs.hasBackendChanges }}
# hasMigrationChanges: ${{ needs.check-for-changes.outputs.hasMigrationChanges }}
#
# release-to-git:
# name: Release to git
# runs-on: ubuntu-latest
# needs: [check-for-changes, deploy-production]
# if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' && !failure() && !cancelled()}}
# permissions:
# id-token: write
# contents: write
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: release
# if: (!failure() && !cancelled())
# uses: ./.github/actions/release-to-git
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}