Sonar #2127
Workflow file for this run
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: Bygg og deploy | |
on: | |
# Only trigger, when the build workflow succeeded | |
workflow_run: | |
workflows: [ "Bygg server" ] | |
types: | |
- completed | |
push: | |
branches-ignore: # Kan legge til disse store feature branchene her | |
- 'uttaksplanbuilder-rework' | |
paths-ignore: | |
# - '**.md' | |
# - '**.MD' | |
- '.gitignore' | |
- '.editorconfig' | |
- 'LICENCE' | |
- 'CODEOWNERS' | |
- 'server/**' | |
- '.github/workflows/build-server.yml' | |
- 'server_for_redirect/**' | |
- '.github/workflows/build-redirect.yml' | |
- '.deploy/planlegger_redirect.yaml' | |
jobs: | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 8 | |
run_install: false | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Run tests | |
run: pnpm exec turbo test | |
create-build-version: | |
name: Create build version | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Print context | |
run: echo "$JSON" | |
env: | |
JSON: ${{ toJSON(github) }} | |
- name: Generate build version | |
id: generate-build-version | |
run: echo "build-version=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_OUTPUT | |
- name: Generate cache tags | |
shell: bash | |
id: generate-cache-tags | |
env: | |
GITHUB_REF_NAME: ${{ github.ref_name }} | |
run: | | |
GITHUB_REF_NAME=${GITHUB_REF_NAME//\//_} | |
echo "cache-tag=$GITHUB_REF_NAME" >> $GITHUB_OUTPUT | |
outputs: | |
build-version: ${{ steps.generate-build-version.outputs.build-version }} | |
cache-tag: ${{ steps.generate-cache-tags.outputs.cache-tag }} | |
build-platform-images: | |
strategy: | |
matrix: | |
platform: ['amd64', 'arm64'] | |
name: Build platform images | |
needs: create-build-version | |
permissions: | |
contents: read | |
packages: write | |
uses: navikt/fp-gha-workflows/.github/workflows/build-app-frontend-pnpm.yml@main | |
with: | |
push-image: ${{ github.ref_name == 'master' }} # default: false | |
platform: ${{ matrix.platform }} | |
cache-tag: ${{ needs.create-build-version.outputs.cache-tag }} | |
secrets: inherit | |
create-manifest: | |
strategy: | |
matrix: | |
app: | |
- 'foreldrepengesoknad' | |
- 'engangsstonad' | |
- 'foreldrepengeoversikt' | |
- 'svangerskapspengesoknad' | |
runs-on: ubuntu-latest | |
name: Create multiplatform image | |
needs: | |
- build-platform-images | |
- test | |
- create-build-version | |
if: ${{ github.ref_name == 'master' }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Print build version | |
run: echo "Generated build-version is ${{ needs.create-build-version.outputs.build-version }}" | |
- name: Login to GitHub Packages Docker Registry | |
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Tag image | |
run: | | |
docker buildx imagetools create \ | |
ghcr.io/navikt/foreldrepengesoknad/${{ matrix.app }}:arm64-${{ github.sha }} \ | |
ghcr.io/navikt/foreldrepengesoknad/${{ matrix.app }}:amd64-${{ github.sha }} \ | |
-t ghcr.io/navikt/foreldrepengesoknad/${{ matrix.app }}:${{ github.sha }} \ | |
-t ghcr.io/navikt/foreldrepengesoknad/${{ matrix.app }}:latest \ | |
-t ghcr.io/navikt/foreldrepengesoknad/${{ matrix.app }}:${{ needs.create-build-version.outputs.build-version }} | |
promote-foreldrepengesoknad-dev: | |
name: Deploy foreldrepengesøknad til dev | |
if: ${{ github.ref_name == 'master' }} | |
needs: | |
- create-manifest | |
- create-build-version | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/foreldrepengesoknad:${{ needs.create-build-version.outputs.build-version }} | |
cluster: dev-gcp | |
app: foreldrepengesoknad | |
secrets: inherit | |
promote-foreldrepengesoknad-prod: | |
name: Deploy foreldrepengesøknad til prod | |
if: ${{ github.ref_name == 'master' }} | |
needs: [promote-foreldrepengesoknad-dev, create-manifest, create-build-version] | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/foreldrepengesoknad:${{ needs.create-build-version.outputs.build-version }} | |
cluster: prod-gcp | |
app: foreldrepengesoknad | |
secrets: inherit | |
promote-foreldrepengeoversikt-dev: | |
name: Deploy foreldrepengeoversikt til dev | |
if: ${{ github.ref_name == 'master' }} | |
needs: | |
- create-manifest | |
- create-build-version | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/foreldrepengeoversikt:${{ needs.create-build-version.outputs.build-version }} | |
cluster: dev-gcp | |
app: foreldrepengeoversikt | |
secrets: inherit | |
promote-foreldrepengeoversikt-prod: | |
name: Deploy foreldrepengeoversikt til prod | |
if: ${{ github.ref_name == 'master' }} | |
needs: [promote-foreldrepengeoversikt-dev, create-manifest, create-build-version] | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/foreldrepengeoversikt:${{ needs.create-build-version.outputs.build-version }} | |
cluster: prod-gcp | |
app: foreldrepengeoversikt | |
secrets: inherit | |
promote-engangsstonad-dev: | |
name: Deploy engangsstonad til dev | |
if: ${{ github.ref_name == 'master' }} | |
needs: | |
- create-manifest | |
- create-build-version | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/engangsstonad:${{ needs.create-build-version.outputs.build-version }} | |
cluster: dev-gcp | |
app: engangsstonad | |
secrets: inherit | |
promote-engangsstonad-prod: | |
name: Deploy engangsstonad til prod | |
if: ${{ github.ref_name == 'master' }} | |
needs: [promote-engangsstonad-dev, create-manifest, create-build-version] | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/engangsstonad:${{ needs.create-build-version.outputs.build-version }} | |
cluster: prod-gcp | |
app: engangsstonad | |
secrets: inherit | |
promote-svangerskapspengesoknad-dev: | |
name: Deploy svangerskapspengesoknad til dev | |
if: ${{ github.ref_name == 'master' }} | |
needs: | |
- create-manifest | |
- create-build-version | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/svangerskapspengesoknad:${{ needs.create-build-version.outputs.build-version }} | |
cluster: dev-gcp | |
app: svangerskapspengesoknad | |
secrets: inherit | |
promote-svangerskapspengesoknad-prod: | |
name: Deploy svangerskapspengesoknad til prod | |
if: ${{ github.ref_name == 'master' }} | |
needs: [promote-svangerskapspengesoknad-dev, create-manifest, create-build-version] | |
uses: navikt/fp-gha-workflows/.github/workflows/deploy-app-pnpm.yml@main | |
with: | |
image: ghcr.io/${{ github.repository }}/svangerskapspengesoknad:${{ needs.create-build-version.outputs.build-version }} | |
cluster: prod-gcp | |
app: svangerskapspengesoknad | |
secrets: inherit |