This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
Deploy release to dev or prod #101
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: Deploy release to dev or prod | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Miljø (støtter q1, q2 og p)' | |
required: true | |
default: 'q2' | |
deploy_version: | |
description: 'Hvilken versjon skal deployes? (kun for master-branchen)' | |
required: true | |
default: '' | |
env: | |
REPONAME: ${{ github.event.repository.name }} | |
APPNAME: ${{ github.event.repository.name }}-frontend | |
ENVIRONMENT: ${{ github.event.inputs.environment }} | |
NAIS_FILE: .nais/nais.yaml | |
MAIN_BRANCH: refs/heads/master | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if correct branch | |
if: github.ref != env.MAIN_BRANCH | |
run: | | |
echo "Jobben skal kun kjøres fra master branch!" | |
exit 1 | |
- name: Set vars | |
id: setVars | |
run: | | |
echo "IMAGE=ghcr.io/${{ github.repository }}/${{ env.REPONAME }}:${{ github.event.inputs.deploy_version }}" >> $GITHUB_ENV | |
- name: Set cluster | |
uses: haya14busa/action-cond@v1 | |
id: cluster | |
with: | |
cond: ${{ github.event.inputs.environment == 'p' }} | |
if_true: 'prod-gcp' | |
if_false: 'dev-gcp' | |
- name: Download artifact | |
uses: dsaltares/fetch-gh-release-asset@master | |
with: | |
version: 'tags/v${{ github.event.inputs.deploy_version }}' | |
file: '${{ env.REPONAME }}-${{ github.event.inputs.deploy_version }}.zip' | |
target: '${{ env.REPONAME }}-${{ github.event.inputs.deploy_version }}.zip' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Unzip artifact (vars-files) | |
uses: montudor/action-zip@v1 | |
with: | |
args: unzip ${{ env.REPONAME }}-${{ github.event.inputs.deploy_version }}.zip -d . | |
- name: Deploy release to dev or prod | |
if: env.ENVIRONMENT == 'q1' || env.ENVIRONMENT == 'q2' || env.ENVIRONMENT == 'p' | |
uses: nais/deploy/actions/deploy@v2 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
PRINT_PAYLOAD: true | |
CLUSTER: ${{ steps.cluster.outputs.value }} | |
RESOURCE: ${{ env.NAIS_FILE }} | |
VAR: image=${{ env.IMAGE }},appName=${{ env.APPNAME }} | |
VARS: .nais/vars-${{ env.ENVIRONMENT }}.yaml | |
WAIT: false |