add ref tag + run tomcat as user www-data (33) #14
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, package and deploy java parts | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
DOCKER_REGISTRY: ghcr.io | |
DOCKER_IMAGE_NAME: ${{ github.repository }} | |
DOCKER_TAG_SHA: ${{ github.sha }} | |
DOCKER_TAG_REF: ${{ github.ref_name }} | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
java-version: [ 17 ] | |
steps: | |
- uses: actions/checkout@v3 | |
# Login against a Docker registry except on PR | |
# https://github.com/docker/login-action | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java-version }} | |
distribution: 'temurin' | |
cache: maven | |
- name: Build war and image with Maven and run tests | |
run: | | |
mvn verify \ | |
-B --fail-at-end --no-transfer-progress --file pom.xml \ | |
-D docker.repository=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }} \ | |
-D docker.tag=${{ env.DOCKER_TAG }} | |
- name: Publish Unit Test Report | |
if: success() || failure() | |
uses: scacap/action-surefire-report@v1 | |
- name: Tag and push image except on PR | |
if: github.event_name != 'pull_request' | |
run: | | |
docker tag \ | |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_TAG_SHA }} \ | |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_TAG_REF }} | |
docker push --all-tags \ | |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_TAG_SHA }} |