Skip to content

Bump docker/build-push-action from 5 to 6 #262

Bump docker/build-push-action from 5 to 6

Bump docker/build-push-action from 5 to 6 #262

Workflow file for this run

name: build image
on:
push:
branches: [ 'master', 'feature/**' ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ 'master' ]
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE: ${{ github.repository }}
GITHUB_PACKAGE_URL: https://maven.pkg.github.com/${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# build
- name: Checkout project
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build artefacts
run: |
mvn --batch-mode verify
# build image
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: dockerfiles/Dockerfile
load: true
tags: ${{ env.DOCKER_IMAGE }}:${{ github.sha }}
- name: Test image
run: |
DOCKER_PID=$(docker run -d -p 8080:80 --rm ${{ env.DOCKER_IMAGE }}:${{ github.sha }} 2>/dev/null)
sleep 10s
curl --fail http://localhost:8080/bgg-api/actuator/health
docker stop $DOCKER_PID
# deploy
- name: Deploy artefacts
if: github.ref == 'refs/heads/master'
run: |
mvn --batch-mode validate jar:jar deploy:deploy -DaltDeploymentRepository=github::default::${{ env.GITHUB_PACKAGE_URL }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker registry
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
if: github.ref == 'refs/heads/master'
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}
- name: Deploy image
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v6
with:
context: .
file: dockerfiles/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/master'
environment:
name: staging
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}/bgg-api/actuator/health
steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: bgg-api-staging
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE_STAGING }}
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:master