no inputs i actions #70
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build and deploy to dev" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**.md' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
APP: aap-kalkulator-frontend | |
IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }}-dev | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} | |
SKIP_YARN_COREPACK_CHECK: true | |
permissions: | |
contents: read | |
id-token: write | |
packages: write | |
outputs: | |
image: ${{ steps.image.outputs.image }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: https://npm.pkg.github.com | |
cache: yarn | |
- name: Enable Corepack | |
run: corepack enable | |
- 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 --immutable | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} | |
- name: Copy env-file for dev | |
run: cp .nais/dev.env .env.local | |
- name: test application | |
run: yarn test | |
- name: check diff on translations | |
run: yarn intl:diff | |
- name: hent tidsstempel | |
run: echo -e "\nNEXT_PUBLIC_LAST_UPDATED=$(date +%m-%d-%Y)" >> .env.local | |
- name: Bygg klient(yarn run build) | |
run: yarn run build | |
- name: Upload static files to NAV CDN | |
uses: nais/deploy/actions/cdn-upload/v2@master | |
with: | |
team: aap | |
source: ./.next/static | |
destination: /${{ env.appname }}/_next | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Setter tag-navn | |
run: echo "TAG=$(date +%m-%d-%Y)-$(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 | |
deploy: | |
name: Deploy til dev | |
needs: build | |
permissions: | |
contents: read | |
id-token: write | |
runs-on: ubuntu-latest | |
env: | |
PRINT_PAYLOAD: true | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
RESOURCE: nais.yaml | |
CLUSTER: dev-gcp | |
VARS: .nais/dev-gcp.yaml | |
IMAGE: ${{needs.build.outputs.image}} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: nais/deploy/actions/deploy@v1 |