deploy dev og prod #340
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 dev og prod | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
packages: write | |
contents: write | |
concurrency: | |
group: deploy_prod | |
cancel-in-progress: true | |
env: | |
IMAGE_TAG: ${{ github.sha }} | |
IMAGE: ghcr.io/${{ github.repository }}/veilarbaktivitet | |
PRINT_PAYLOAD: true | |
jobs: | |
test-build-and-push: | |
name: Test, build and push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
- name: Execute Gradle build | |
run: ./gradlew build --scan | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ${{ env.IMAGE }}:${{ env.IMAGE_TAG }} | |
deploy-dev: | |
name: Deploy application to dev | |
needs: test-build-and-push | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Deploy application | |
uses: nais/deploy/actions/deploy@v1 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: dev-fss | |
RESOURCE: nais/nais-dev.yaml | |
VAR: version=${{ env.IMAGE_TAG }},namespace=q1 | |
deploy-prod: | |
name: Deploy application to prod | |
needs: deploy-dev | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Deploy application | |
uses: nais/deploy/actions/deploy@v1 | |
env: | |
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} | |
CLUSTER: prod-fss | |
RESOURCE: nais/nais.yaml | |
VAR: version=${{ env.IMAGE_TAG }} |