Build and deploy to q1 #5
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 and deploy to q | |
run-name: Build and deploy to ${{ github.event.inputs.environment }} | |
permissions: | |
deployments: write | |
packages: write | |
contents: write | |
id-token: write | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: 'Miljø det skal deployes til' | |
default: 'q2' | |
required: true | |
options: | |
- 'q1' | |
- 'q2' | |
- 'q1-experimental' | |
- 'q2-experimental' | |
version: | |
description: 'New version number, leave blank for auto increment.' | |
required: false | |
default: '' | |
env: | |
IMAGE: europe-north1-docker.pkg.dev/nais-management-233d/eessibasis/eux-web-app | |
jobs: | |
build: | |
name: 'Build Docker Image' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Git User | |
uses: fregante/setup-git-user@v2 | |
- name: 'Setter dato og commit variabel' | |
run: | | |
export TZ=CET | |
echo "DATE=$(date "+%Y-%m-%d--%H-%M-%S")" >> $GITHUB_ENV | |
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
- name: 'Setter Image' | |
id: versions | |
run: echo "version=${{ env.DATE }}---${{ env.COMMIT_HASH }}" >> $GITHUB_OUTPUT | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: 'Setup Node' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
registry-url: https://npm.pkg.github.com/ | |
scope: "@navikt" | |
- name: 'Install' | |
run: npm install --force | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} | |
- name: 'Bygg' | |
run: npm run build | |
- name: Push docker image to GAR | |
uses: nais/docker-build-push@v0 | |
id: docker-build-push | |
with: | |
team: eessibasis | |
tag: ${{ steps.versions.outputs.version }} | |
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} | |
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} | |
- name: Echo Version | |
run: echo "### Version ${{ steps.versions.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
outputs: | |
docker-image: > | |
${{ env.IMAGE }}:${{ steps.versions.outputs.version }} | |
deploy-q2: | |
name: 'Deploy to ${{ github.event.inputs.environment }}' | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: 'Calling nais deploy action for q2' | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
CLUSTER: dev-gcp | |
RESOURCE: .nais/nais.yaml | |
VAR: image=${{ needs.build.outputs.docker-image }} | |
VARS: .nais/${{ github.event.inputs.environment }}.yaml | |
PRINT_PAYLOAD: true | |