Skip to content

[publisering] skjema "Melding om tildelt barnehageplass", monorepo re… #2758

[publisering] skjema "Melding om tildelt barnehageplass", monorepo re…

[publisering] skjema "Melding om tildelt barnehageplass", monorepo re… #2758

name: "Deploy 'fyllut'"
on:
push:
branches:
- master
- dev-deploy
env:
IMAGE_FYLLUT_BASE: "europe-north1-docker.pkg.dev/nais-management-233d/skjemadigitalisering/skjemabygging-formio-${{ github.ref == 'refs/heads/master' && 'fyllut-base' || 'fyllut-base-dev' }}"
MONOREPO_BASE_URL: "https://raw.githubusercontent.com/navikt/skjemabygging-formio"
PUSHER_APP_SECRET: ${{ secrets.PUSHER_APP_SECRET }}
BYGGER_URL: "https://skjemabygging.nav.no"
concurrency: deploy-${{ github.ref }}
jobs:
package-and-push-fyllut:
name: "Package 'fyllut'"
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
packages: "read"
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Read monorepo commit sha
run: echo "MONOREPO_GIT_SHA=$(cat MONOREPO)" >> $GITHUB_ENV
- name: "Build and push Docker image"
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: skjemadigitalisering
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: ${{ github.ref == 'refs/heads/master' && 'fyllut' || 'fyllut-dev' }}
build_args: |
git_sha=${{ github.sha }}
monorepo_git_sha=${{ env.MONOREPO_GIT_SHA }}
skjema_dir=forms
translation_dir=translations
resources_dir=resources
image_fyllut_base=${{ env.IMAGE_FYLLUT_BASE }}
pull: true
- name: "Notify job failure"
if: ${{ github.ref == 'refs/heads/master' && failure() }}
run: yarn && cat $GITHUB_EVENT_PATH | node bin/notifyDeploy.mjs failure
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
deploy-fyllut-to-prod:
name: "Deploy 'fyllut' to prod"
if: github.ref == 'refs/heads/master'
needs: "package-and-push-fyllut"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "lts/*"
- name: Fetch NAIS config
run: bin/fetchNaisConfig.sh prod fyllut-config
- name: "Deploy to prod"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "prod-gcp"
RESOURCE: "./fyllut-config/config.yaml"
VARS: "./fyllut-config/prod.yaml"
VAR: "image=${{ needs.package-and-push-fyllut.outputs.image }}"
- name: "Notify job success"
if: ${{ success() }}
run: yarn && cat $GITHUB_EVENT_PATH | node bin/notifyDeploy.mjs success
- name: "Notify job failure"
if: ${{ failure() }}
run: yarn && cat $GITHUB_EVENT_PATH | node bin/notifyDeploy.mjs failure
notify-prod-deployment-failure:
name: "Notify prod deployment failure"
if: failure() && github.ref == 'refs/heads/master'
needs: deploy-fyllut-to-prod
runs-on: ubuntu-latest
steps:
- name: "Slack notification"
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Deploy av fyllut til prod har feilet."
SLACK_COLOR: failure
deploy-fyllut-to-dev:
name: "Deploy 'fyllut' to dev"
if: github.ref == 'refs/heads/dev-deploy'
needs: "package-and-push-fyllut"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch NAIS config
run: bin/fetchNaisConfig.sh dev fyllut-config
- name: "Deploy to dev"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "dev-gcp"
RESOURCE: "./fyllut-config/config.yaml"
VARS: "./fyllut-config/dev.yaml"
VAR: "image=${{ needs.package-and-push-fyllut.outputs.image }}"
deploy-fyllut-delingslenke-to-dev:
name: "Deploy 'fyllut'-delingslenke to dev"
if: github.ref == 'refs/heads/dev-deploy'
needs: "package-and-push-fyllut"
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch NAIS config
run: bin/fetchNaisConfig.sh dev-delingslenke fyllut-config
- name: "Deploy to dev"
uses: "nais/deploy/actions/deploy@v2"
env:
CLUSTER: "dev-gcp"
RESOURCE: "./fyllut-config/config.yaml"
VARS: "./fyllut-config/dev-delingslenke.yaml"
VAR: "image=${{ needs.package-and-push-fyllut.outputs.image }}"
notify-dev-deployment-failure:
name: "Notify dev deployment failure"
if: failure() && (github.ref == 'refs/heads/dev-deploy')
needs: [deploy-fyllut-to-dev, deploy-fyllut-delingslenke-to-dev]
runs-on: ubuntu-latest
steps:
- name: "Slack notification"
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEV }}
SLACK_FOOTER: "Deploy av fyllut til dev har feilet. Undersøk om det kan påvirke neste publisering fra byggeren."
SLACK_COLOR: "#ff9100"