pre-commit hook (to enforce non-failure on tests) #59
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 & publish to docker hub | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '30 5 * * *' | |
permissions: | |
contents: read | |
actions: read | |
checks: write | |
packages: write | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
actions: read | |
checks: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
settings-path: ${{ github.workspace }} # location for the settings.xml file | |
cache: maven | |
- name: Run the Maven verify phase | |
run: mvn --batch-mode -Dsnyk.skip verify | |
- run: mkdir staging && cp target/*.jar staging | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Package | |
path: staging | |
# - name: Publish Test Report | |
# if: success() || failure() | |
# uses: ScaCap/[email protected] | |
# - uses: dorny/[email protected] | |
# if: success() || failure() | |
# with: | |
# name: Junit Test Report | |
# path: 'target/surefire-reports/*.xml' | |
# reporter: java-junit | |
# fail-on-error: true | |
# | |
- name: Set short git commit SHA | |
id: vars | |
run: | | |
calculatedSha=$(git rev-parse --short ${{ github.sha }}) | |
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish container image to GitHub Container registry | |
id: publish | |
env: | |
REGISTRY: ${{ env.REGISTRY }} | |
DOCKER_USERNAME: ${{ github.actor }} | |
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
run: mvn --batch-mode clean compile jib:build -D jib.to.tags=latest,${{ env.COMMIT_SHORT_SHA }} | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ secrets.DOCKERHUB_REGISTRY }} | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PAT }} | |
- name: Publish container image to Docker Hub | |
id: publish_dockerhub | |
env: | |
REGISTRY: ${{ secrets.DOCKERHUB_REGISTRY }} | |
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PAT }} | |
run: mvn --batch-mode clean compile jib:build -D jib.to.tags=latest,${{ env.COMMIT_SHORT_SHA }} |