Skip to content

Build image and deploy to production #9

Build image and deploy to production

Build image and deploy to production #9

name: 'Build image and deploy to production'
on:
workflow_call:
workflow_run:
workflows: ['Build code and run tests']
branches: [master]
types:
- completed
jobs:
build-image:
name: 'Build Image for Deploy'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: 'Copy appropriate env file to root'
shell: bash
run: |
echo "Copying nais/envs/.env.production..."
cp nais/envs/.env.production .env.production
- name: 'Build npm project'
uses: navikt/sosialhjelp-ci/actions/build-npm@main
with:
node-version: 20
build-less: 'false'
reader-token: ${{ secrets.READER_TOKEN }}
run-test: 'false'
- name: 'Upload static files to cdn'
id: upload
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: teamdigisos
source: ./.next/static
destination: "/sosialhjelp-innsyn/_next"
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
- name: Build and push docker image to GAR
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: teamdigisos
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
image_suffix: production
deploy-gcp:
name: 'Deploy to production'
permissions:
id-token: write
contents: read
needs: build-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'Deploy til prod'
uses: nais/deploy/actions/deploy@v2
env:
RESOURCE: nais/prod/prod.yaml
CLUSTER: prod-gcp
REF: ${{ github.sha }}
PRINT_PAYLOAD: true
VAR: image=${{ needs.build-image.outputs.image }}