de.lehmann.devops/.gitea/workflows/publish-docker-springboot.yaml
2024-06-04 08:40:19 +02:00

49 lines
2.0 KiB
YAML

name: Publish docker workflow
on:
workflow_call:
jobs:
publish_docker:
name: Build and publish docker image
runs-on: docker-ubuntu
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Download build artifacts (dist files)
uses: actions/download-artifact@v3
with:
name: artifacts-build
path: build/
- name: Setup docker buildx environment
uses: docker/setup-buildx-action@v3
- name: Login to docker registry
uses: docker/login-action@v3
with:
registry: ${{ vars.CONTAINER_REGISTRY_URL }}
username: ${{ vars.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_TOKEN }}
- name: Setup environment variables from "build/env-setup.sh"
run: |
source build/env-setup.sh
- name: Show environment variables
run: |
echo "The job_id is: $GITHUB_JOB" # reference the default environment variables
echo "The id of this action is: $GITHUB_ACTION" # reference the default environment variables
echo "The run id is: $GITHUB_RUN_ID"
echo "The GitHub Actor's username is: $GITHUB_ACTOR"
echo "GitHub SHA: $GITHUB_SHA"
echo "APPLICATION_FILE_BINARY: $APPLICATION_FILE_BINARY"
echo "APPLICATION_NAME: $APPLICATION_NAME"
echo "APPLICATION_PORT: $APPLICATION_PORT"
echo "APPLICATION_JAVA_VERSION: $APPLICATION_JAVA_VERSION"
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: "${{ vars.CONTAINER_REGISTRY_URL }}/${{gitea.repository}}:latest"
build-args: |
FILE_BINARY=${{ env.APPLICATION_FILE_BINARY }}
NAME_APPLICATION=${{ env.APPLICATION_NAME }}
PORT_EXPOSURE=${{ env.APPLICATION_PORT }}
JAVA_VERSION=${{ env.APPLICATION_JAVA_VERSION }}