Skip to content

Merge pull request #87 from TEIC/dependabot/maven/org.apache.maven.pl… #192

Merge pull request #87 from TEIC/dependabot/maven/org.apache.maven.pl…

Merge pull request #87 from TEIC/dependabot/maven/org.apache.maven.pl… #192

Workflow file for this run

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: maven and docker
on:
push:
branches: [ main, dev ]
tags: [ v* ]
pull_request:
branches: [ main, dev ]
jobs:
build:
name: compile maven package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
- name: maven-settings
uses: s4u/[email protected]
with:
servers: '[{"id": "edirom", "username": "${github.actor}", "password": "${GITHUB_TOKEN}"},{"id": "teic", "username": "${github.actor}", "password": "${GITHUB_TOKEN}"}]'
- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn clean package --file pom.xml
- name: Upload Maven build artifact
uses: actions/upload-artifact@v4
with:
name: artifact
path: /home/runner/work/TEIGarage/TEIGarage/target/teigarage.war
docker:
name: build the Docker image
needs: build
runs-on: ubuntu-latest
#don't run docker build on pull request at all
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: artifact
path: artifact/
- name: Display structure of downloaded files
run: ls -R
working-directory: artifact
# use the current user to log into the
# GitHub container registry
- name: Log in to GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Login against DockerHub registry
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.PETERS_DOCKERHUB_USERNAME }}
password: ${{ secrets.PETERS_DOCKERHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/teic/teigarage
teic/teigarage
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILDTYPE=github
# Use current README for DockerHub description
- name: Update repo description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.PETERS_DOCKERHUB_USERNAME }}
password: ${{ secrets.PETERS_DOCKERHUB_TOKEN }}
repository: teic/teigarage