# 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. ```yaml 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`. - **username** (optional): - **Type:** `string` - **Default:** `${{ vars.REGISTRY_USERNAME }}` - **Description:** Username for the Docker registry authentication. Defaults to authenticated `registry` user. - **password** (optional): - **Type:** `string` - **Default:** `${{ vars.REGISTRY_PASSWORD }}` - **Description:** Password for the Docker registry authentication. Defaults to authenticated `registry` user. ### Steps 1. **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. 2. **Login to Docker Registry:** - **Action:** `docker/login-action@v3` - **Description:** Logs into the Docker registry (`git.qlic.nl`) using the provided `username` and `password` inputs. - **Inputs:** - `registry`: Set to `git.qlic.nl` - `username`: Provided via `${{ inputs.username }}` - `password`: Provided via `${{ inputs.password }}` 3. **Build Docker Image:** - **Command:** ```bash 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 default `latest` if not provided) and the current Git commit SHA. 4. **Push Docker Image:** - **Command:** ```bash 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.