Build Workflow
This is a workflow designed to automate the process of building and pushing Docker images to the registry. The workflow is triggered through the workflow_call
event, allowing it to be reused in other workflows or repositories.
Usage Example
In this example, the build
workflow is invoked with a custom tag
, username
, and password
. The workflow will build and push a Docker image using the provided parameters.
jobs:
build:
uses: your-repo/.github/workflows/build.yml@main
with:
tag: v1.0.0
username: my-docker-username
password: ${{ secrets.DOCKER_PASSWORD }}
build-args: |
PHP_VERSION=8.4
Input Parameters
-
tag (optional):
- Type:
string
- Default:
latest
- Description: Tag to be assigned to the Docker image. If not provided, it defaults to
latest
.
- Type:
-
username (optional):
- Type:
string
- Default:
${{ vars.REGISTRY_USERNAME }}
- Description: Username for the Docker registry authentication. Defaults to authenticated
registry
user.
- Type:
-
password (optional):
- Type:
string
- Default:
${{ vars.REGISTRY_PASSWORD }}
- Description: Password for the Docker registry authentication. Defaults to authenticated
registry
user.
- Type:
Steps
-
Checkout Code:
- Action:
actions/checkout@v4
- Description: This step checks out the code from the repository, ensuring the latest version of the code is available for building the Docker image.
- Action:
-
Login to Docker Registry:
- Action:
docker/login-action@v3
- Description: Logs into the Docker registry (
git.qlic.nl
) using the providedusername
andpassword
inputs. - Inputs:
registry
: Set togit.qlic.nl
username
: Provided via${{ inputs.username }}
password
: Provided via${{ inputs.password }}
- Action:
-
Build Docker Image:
- Command:
docker build . -t ${{ vars.REGISTRY }}/${{ gitea.repository }}:${{ inputs.tag }} -t ${{ vars.REGISTRY }}/${{ gitea.repository }}:${{ gitea.sha }}
- Description: Builds a Docker image from the current code. The image is tagged with both the user-provided
tag
(or the defaultlatest
if not provided) and the current Git commit SHA.
- Command:
-
Push Docker Image:
- Command:
docker push ${{ vars.REGISTRY }}/${{ gitea.repository }} --all-tags
- Description: Pushes the built Docker image to the Docker registry (
git.qlic.nl
), ensuring that all tags are pushed.
- Command:
Description
v1
Latest