This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
Bump docker/login-action from 2 to 3 #1183
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, 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@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
- uses: gradle/gradle-build-action@v2.4.2 | |
with: | |
arguments: build --info installDist | |
- name: Set up Docker Buildx | |
if: github.ref == 'refs/heads/main' | |
uses: docker/setup-buildx-action@v2 | |
- 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: Build and push | |
if: github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v4 | |
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@v3 | |
- uses: nais/deploy/actions/deploy@v1 | |
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@v3 | |
- uses: nais/deploy/actions/deploy@v1 | |
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 |