Skip to content

Bygg og deploy AAP Søknad #273

Bygg og deploy AAP Søknad

Bygg og deploy AAP Søknad #273

Workflow file for this run

name: Build and deploy aap-soknad to dev
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '**.md'
env:
IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }}
jobs:
build:
name: build
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.image }}
permissions:
contents: write
id-token: write
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://npm.pkg.github.com
cache: yarn
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }}
- name: install dependencies Yarn
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Copy env-file for dev
run: cp .nais/dev.env .env.local
# - name: client tests
# run: yarn test
- name: check diff on translations
run: yarn intl:diff
- name: Bygg klient(yarn run build)
run: |
npx browserslist@latest --update-db
yarn run build
- name: Upload static files to NAV CDN dev
uses: navikt/frontend/actions/cdn-upload/v1@main
with:
cdn-team-name: aap
source: ./.next/static
destination: /aap-soknad/_next
# - name: Install Playwright Browsers
# run: npx playwright install --with-deps
# - name: Run Playwright tests
# run: yarn playwright test
# - uses: actions/upload-artifact@v3
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 30
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Setter tag-navn
run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: Setter image-navn
id: image
run: |
echo "IMAGE=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_ENV
echo "image=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_OUTPUT
- name: Login GAR
uses: nais/login@v0
with:
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
team: aap
- name: Build and push Docker
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
tags: ${{ env.IMAGE }}:latest
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
deployAppToDev:
name: Deploy app to dev
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy to DEV
uses: nais/deploy/actions/deploy@v1
env:
IMAGE: ${{needs.build.outputs.image}}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yaml
VARS: .nais/dev.yaml