Skip to content

Oppgradere gradle

Oppgradere gradle #107

name: Build and deploy
on: [push]
env:
IMAGE: ghcr.io/${{ github.repository }}/${{ github.repository }}:${{ github.sha }}
jobs:
build:
name: Build and publish Docker image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3.2.0
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 18
- uses: gradle/gradle-build-action@v2
with:
arguments: build --info
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
tags: ${{ env.IMAGE }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Archive NAIS yaml
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v3
with:
name: nais-yaml
path: nais
deploy-dev:
name: Deploy to dev
needs: [build]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Fetch NAIS yaml
uses: actions/download-artifact@v3
with:
name: nais-yaml
path: nais
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais/nais.yaml
VAR: KAFKA_POOL=nav-dev
PRINT_PAYLOAD: true
deploy-prod:
name: Deploy to Production
needs: [deploy-dev]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Fetch NAIS yaml
uses: actions/download-artifact@v3
with:
name: nais-yaml
path: nais
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/nais.yaml
VAR: KAFKA_POOL=nav-prod
PRINT_PAYLOAD: true