Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Bump gradle/gradle-build-action from 2 to 3 #254

Bump gradle/gradle-build-action from 2 to 3

Bump gradle/gradle-build-action from 2 to 3 #254

Workflow file for this run

name: Build, push, and deploy
on: push
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
PRINT_PAYLOAD: true
jobs:
build:
name: Test, build and push
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- uses: gradle/gradle-build-action@v3
with:
arguments: build --info installDist
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Docker Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build and push
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ env.IMAGE }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Notify Slack in case of build failure
if: failure() && github.ref == 'refs/heads/main'
run: |
curl -X POST --data-urlencode "payload={ \"attachments\": [{ \"pretext\": \"[${{ github.event.repository.name }}] Build failed :cry:\", \"color\": \"danger\", \"fields\": [ { \"title\": \"Author\", \"value\": \"$AUTHOR\", \"short\": false }, { \"title\": \"Commit\", \"value\": \"<https://github.com/${{ github.repository }}/commit/$GITHUB_SHA|$GITHUB_SHA>\", \"short\": false } ] }] }" $WEBHOOK_URL
env:
BRANCH: ${{ github.ref }}
AUTHOR: ${{ github.event.pusher.name }}
WEBHOOK_URL: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }}
deploy-dev:
name: Deploy to NAIS dev
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yml
VAR: image=${{ env.IMAGE }},name=${{ github.event.repository.name }}
VARS: .nais/vars/dev.yml
# deploy-prod:
# name: Deploy to NAIS prod
# needs: deploy-dev
# if: github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: nais/deploy/actions/deploy@v2
# env:
# APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
# CLUSTER: prod-gcp
# RESOURCE: .nais/nais.yml
# VAR: image=${{ env.IMAGE }},name=${{ github.event.repository.name }}
# VARS: .nais/vars/prod.yml