Skip to content

Merge branch 'main' into umami #1531

Merge branch 'main' into umami

Merge branch 'main' into umami #1531

Workflow file for this run

name: Build and deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
packages: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: docker-build-push
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: teamdagpenger
push_image: true
dockerfile: Dockerfile
docker_context: .
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
build_secrets: NODE_AUTH_TOKEN=${{ secrets.READER_TOKEN }}
build-demo:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
packages: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: docker-build-push
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: teamdagpenger
push_image: true
dockerfile: Dockerfile
docker_context: .
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
build_args: RUNTIME_ENVIRONMENT=demo
build_secrets: NODE_AUTH_TOKEN=${{ secrets.READER_TOKEN }}
- name: Build static files
uses: docker/build-push-action@v5
with:
target: export
outputs: type=local,dest=build
secrets: NODE_AUTH_TOKEN=${{ secrets.READER_TOKEN }}
- name: Upload static files
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: teamdagpenger
source: ./build/client
destination: '/dp-rapportering-frontend/'
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache node_modules
uses: actions/cache@v4
id: node_modules
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'npm'
registry-url: 'https://npm.pkg.github.com'
- run: npm ci --ignore-scripts
if: steps.node_modules.outputs.cache-hit != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- run: npm run test
deploy-demo:
needs: [build-demo, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
VAR: image=${{ needs.build-demo.outputs.image }},githubSha=${{ github.sha }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.demo.yaml
VARS: .nais/vars-demo.yaml
PRINT_PAYLOAD: true
deploy-dev:
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
VAR: image=${{ needs.build.outputs.image }},githubSha=${{ github.sha }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yaml
VARS: .nais/vars-dev.yaml
PRINT_PAYLOAD: true
deploy-prod:
needs: [build, test]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
VAR: image=${{ needs.build.outputs.image }},githubSha=${{ github.sha }}
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: .nais/nais.yaml
VARS: .nais/vars-prod.yaml
PRINT_PAYLOAD: true