refactor views #9
This file contains hidden or 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: create and publish docker container | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ 'v*.*.*' ] # publish semver tags as releases. | |
| workflow_call: | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| PROJECT_DIRECTORY: . | |
| jobs: | |
| build: | |
| if: github.actor != 'dependabot[bot]' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: set up jdk | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: build with maven | |
| run: mvn clean package --batch-mode -Pproduction | |
| - name: extract project version | |
| id: extract_version | |
| run: | | |
| echo "MAVEN_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_OUTPUT | |
| echo "MAVEN_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT | |
| - name: login to docker hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: extract docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_NAME }} | |
| tags: | | |
| # set latest tag for default branch | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=semver,pattern={{version}} | |
| type=raw,value=${{ steps.extract_version.outputs.MAVEN_VERSION }} | |
| - name: build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ${{ env.PROJECT_DIRECTORY }} | |
| push: true | |
| platforms: linux/amd64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| APP_NAME=${{ steps.extract_version.outputs.MAVEN_NAME }} | |
| APP_VERSION=${{ steps.extract_version.outputs.MAVEN_VERSION }} |