Deploying feature/wonderwall to preprod #304
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: 'Build Image and Deploy to Dev' | |
run-name: Deploying ${{ github.ref_name }} to ${{ github.event.inputs.config-file-name }} | |
on: | |
workflow_dispatch: | |
inputs: | |
config-file-name: | |
description: 'Config-fil som skal deployes' | |
required: true | |
default: 'mock' | |
type: choice | |
options: | |
- 'dev' | |
- 'mock' | |
- 'q0' | |
- 'preprod' | |
workflow_call: | |
inputs: | |
config-file-name: | |
required: true | |
type: string | |
env: | |
DOCKER_IMAGE_POSTFIX: ghcr.io/${{ github.repository }}/${{ github.event.repository.name }}-${{ inputs.config-file-name }} | |
jobs: | |
build-image: | |
name: 'Build Image for Deploy' | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
id-token: write | |
outputs: | |
image-tag: ${{ steps.artifact-version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Copy appropriate env file to root' | |
shell: bash | |
run: | | |
echo "Copying nais/envs/.env.${{ inputs.config-file-name }}..." | |
cp nais/envs/.env.${{ inputs.config-file-name }} .env.production | |
- name: 'Build npm project' | |
uses: navikt/sosialhjelp-ci/actions/build-npm@main | |
with: | |
node-version: 20 | |
build-less: 'false' | |
reader-token: ${{ secrets.READER_TOKEN }} | |
run-test: 'false' | |
- name: 'Upload static files to cdn' | |
id: upload | |
uses: nais/deploy/actions/cdn-upload/v2@master | |
with: | |
team: teamdigisos | |
source: ./.next/static | |
destination: "/sosialhjelp-innsyn/_next" | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
- name: 'Create artifact version' | |
id: artifact-version | |
uses: navikt/sosialhjelp-ci/actions/create-artifact-version@v2 | |
- name: 'Release Tag' | |
uses: ncipollo/release-action@v1 | |
env: | |
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }} | |
with: | |
tag: ${{ steps.artifact-version.outputs.version }} | |
commit: ${{ github.sha }} | |
allowUpdates: true | |
- name: 'Login to GitHub Docker Registry if GitHub Token Provided' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Build and Push Docker Image' | |
uses: navikt/sosialhjelp-ci/actions/build-and-push-docker-image@v2 | |
with: | |
artifact-version: ${{ steps.artifact-version.outputs.version }} | |
image-name: ${{ env.DOCKER_IMAGE_POSTFIX }} | |
deploy-gcp: | |
name: 'Deploy to development' | |
permissions: | |
id-token: write | |
if: ${{ inputs.config-file-name != 'q0' }} | |
needs: build-image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: 'Deploy til dev' | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
RESOURCE: nais/dev/${{ inputs.config-file-name }}.yaml | |
CLUSTER: dev-gcp | |
REF: ${{ github.sha }} | |
PRINT_PAYLOAD: true | |
IMAGE: ${{ env.DOCKER_IMAGE_POSTFIX }}:${{ needs.build-image.outputs.image-tag }} |