name: Build and publish to ECR

on:
  workflow_dispatch:
    branches:
      - main
  push:
    branches:
      - main
    paths-ignore:
      - "Jenkinsfile"
      - ".git**"

jobs:
  build-publish-image-to-ecr:
    uses: alphagov/govuk-infrastructure/.github/workflows/ci-ecr.yaml@main
    secrets:
      AWS_GOVUK_ECR_ACCESS_KEY_ID: ${{ secrets.AWS_GOVUK_ECR_ACCESS_KEY_ID }}
      AWS_GOVUK_ECR_SECRET_ACCESS_KEY: ${{ secrets.AWS_GOVUK_ECR_SECRET_ACCESS_KEY }}

name: CI

on:
  workflow_dispatch:
    branches:
      - main
  push:
    branches:
      - main
    paths-ignore:
      - "Jenkinsfile"
      - ".git**"

jobs:
  build-and-publish-image:
    name: Build and publish image
    uses: alphagov/govuk-infrastructure/.github/workflows/ci-ecr.yaml@main
    secrets:
      AWS_GOVUK_ECR_ACCESS_KEY_ID: ${{ secrets.AWS_GOVUK_ECR_ACCESS_KEY_ID }}
      AWS_GOVUK_ECR_SECRET_ACCESS_KEY: ${{ secrets.AWS_GOVUK_ECR_SECRET_ACCESS_KEY }}
  trigger-deploy-to-integration:
    name: Trigger deploy to integration
    needs: build-and-publish-image
    uses: alphagov/govuk-infrastructure/.github/workflows/deploy.yaml@main
    secrets:
      GOVUK_CI_GITHUB_API_TOKEN: ${{ secrets.GOVUK_CI_GITHUB_API_TOKEN }}

Update CI workflow to trigger deploy to integration
 Update CI workflow to trigger deploy to integration

 This adds an additional job to the CI workflow to run a reusable
 workflow that writes the newly built image tag to helm charts file.
 This triggers ArgoCD to deploy the integration.
