Skip to content

chore(deps): go mod tidy #457

chore(deps): go mod tidy

chore(deps): go mod tidy #457

name: "Build and deploy"
on:
push:
release:
types: [published]
workflow_dispatch:
inputs:
module:
description: "Module to build and deploy"
required: true
type: choice
options:
- fullstack
- frontend
- backend
- metabase
behavior:
description: Workflow behavior
type: choice
options:
- deploy-dev
- test-only
- deploy-only
required: true
permissions:
contents: write
packages: write
id-token: write
jobs:
evaluate-build-module:
permissions: write-all
name: Evaluate modules to build
runs-on: ubuntu-latest
outputs:
build_module: ${{ steps.set-module.outputs.build_module }}
build_metabase: ${{ steps.set-module.outputs.build_metabase }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check change
id: check-change
uses: dorny/paths-filter@v3
with:
filters: |
frontend:
- 'frontend/**'
- '.github/workflows/build-and-deploy-frontend.yml'
- '.github/workflows/build-and-deploy.yml'
backend:
- '!frontend/**'
metabase:
- '.metabase_version'
- '.nais/dev/metabase/**'
- '.nais/prod/metabase/**'
- '.nais/vars.yaml'
ref: ${{ github.ref_name }}
- name: Set module to build and deploy
id: set-module
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "build_module=${{ github.event.inputs.module }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "release" ]; then
echo "build_module=fullstack" >> $GITHUB_OUTPUT
elif [ "${{ steps.check-change.outputs.frontend }}" == 'true' ] && [ "${{ steps.check-change.outputs.backend }}" == 'false' ]; then
echo "build_module=frontend" >> $GITHUB_OUTPUT
elif [ "${{ steps.check-change.outputs.frontend }}" == 'false' ] && [ "${{ steps.check-change.outputs.backend }}" == 'true' ]; then
echo "build_module=backend" >> $GITHUB_OUTPUT
elif [ "${{ steps.check-change.outputs.frontend }}" == 'true' ] && [ "${{ steps.check-change.outputs.backend }}" == 'true' ]; then
echo "build_module=fullstack" >> $GITHUB_OUTPUT
else
echo "build_module=none" >> $GITHUB_OUTPUT
fi
if [ "${{ github.event.inputs.module }}" == 'metabase' ] || [ "${{ github.event.inputs.module }}" == 'fullstack' ]; then
echo "build_metabase=true" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" == "release" ]; then
echo "build_metabase=true" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" != "workflow_dispatch" ] && [ "${{ steps.check-change.outputs.metabase }}" == 'true' ]; then
echo "build_metabase=true" >> $GITHUB_OUTPUT
else
echo "build_metabase=false" >> $GITHUB_OUTPUT
fi
- name: Show modules to build
run: |
echo "Modules to build: ${{ steps.set-module.outputs.build_module }}"
echo "Build metabase: ${{ steps.set-module.outputs.build_metabase }}"
evaluate-deploy-environment:
name: Evaluate environments to deploy
runs-on: ubuntu-latest
outputs:
deploy_env: ${{ steps.set-environment.outputs.deploy_env }}
notest: ${{ steps.set-environment.outputs.notest }}
steps:
- name: Set environment based on event
id: set-environment
run: |
if [ ${{ github.event_name }} == push ]; then
if [ ${{ github.ref }} == 'refs/heads/main' ]; then
echo "deploy_env=prod-and-dev" >> $GITHUB_OUTPUT
else
echo "deploy_env=none" >> $GITHUB_OUTPUT
fi
elif [ ${{ github.event_name }} == release ]; then
echo "deploy_env=prod-only" >> $GITHUB_OUTPUT
elif [ ${{ github.event_name }} == workflow_dispatch ]; then
if [ ${{ github.event.inputs.behavior }} == 'deploy-dev' ]; then
echo "deploy_env=dev-only" >> $GITHUB_OUTPUT
elif [ ${{ github.event.inputs.behavior }} == 'deploy-only' ]; then
echo "deploy_env=dev-only" >> $GITHUB_OUTPUT
echo "notest=true" >> $GITHUB_OUTPUT
elif [ ${{ github.event.inputs.behavior }} == 'test-only' ]; then
echo "deploy_env=none" >> $GITHUB_OUTPUT
fi
fi
- name: Show environments to deploy
run: |
echo "Deploy to: ${{ steps.set-environment.outputs.deploy_env }}"
echo "Bypass test: ${{ steps.set-environment.outputs.notest }}"
call-build-and-deploy-frontend:
needs: [evaluate-deploy-environment, evaluate-build-module]
name: Frontend
if: ${{ needs.evaluate-build-module.outputs.build_module == 'fullstack' || needs.evaluate-build-module.outputs.build_module == 'frontend' }}
uses: ./.github/workflows/build-and-deploy-frontend.yml
with:
deploy_env: ${{ needs.evaluate-deploy-environment.outputs.deploy_env }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
secrets: inherit
call-build-and-deploy-backend:
needs: [evaluate-deploy-environment, evaluate-build-module]
name: Backend
if: ${{ needs.evaluate-build-module.outputs.build_module == 'fullstack' || needs.evaluate-build-module.outputs.build_module == 'backend' }}
uses: ./.github/workflows/build-and-deploy-backend.yml
with:
deploy_env: ${{ needs.evaluate-deploy-environment.outputs.deploy_env }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
notest: ${{ needs.evaluate-deploy-environment.outputs.notest }}
secrets: inherit
call-build-and-deploy-metabase:
needs: [evaluate-deploy-environment, evaluate-build-module]
name: Metabase
if: ${{ needs.evaluate-build-module.outputs.build_metabase == 'true' }}
uses: ./.github/workflows/deploy-metabase.yaml
with:
deploy_env: ${{ needs.evaluate-deploy-environment.outputs.deploy_env }}
secrets: inherit