A composite GitHub Action that builds and pushes Docker images tagged with a branch name and git tags.
Builds Docker images using make docker-build and pushes them with make docker-push. Images are tagged with the caller-specified branch name and any git tags pointing at HEAD. Golang-style version tags (e.g., v1.2.3) have the leading v stripped automatically.
- uses: ./.github/actions/docker-publish-action with: docker-registry: "docker.io" docker-repository: "myorg" image-name: "myapp" branch-tag: ${{ github.ref_name }} docker-username: ${{ secrets.DOCKER_USERNAME }} docker-password: ${{ secrets.DOCKER_PASSWORD }}
| Input | Required | Default | Description |
|---|---|---|---|
docker-registry | No | docker.io | Docker registry URL |
docker-repository | Yes | — | Docker repository prefix |
image-name | Yes | — | Name of the Docker image |
branch-tag | Yes | — | Branch name to use as a Docker image tag |
extra-environment-vars | No | "" | Extra environment variables for make commands |
docker-username | Yes | — | Docker registry username |
docker-password | Yes | — | Docker registry password |
name: Publish Docker Image on: push: branches: [main] tags: ["v*"] jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: ./.github/actions/docker-publish-action with: docker-registry: "docker.io" docker-repository: "voltha" image-name: "voltha-northbound" branch-tag: ${{ github.ref_name }} docker-username: ${{ secrets.DOCKER_USERNAME }} docker-password: ${{ secrets.DOCKER_PASSWORD }}
make docker-build with DOCKER_TAG set to the branch-tag inputmake docker-build for each git tag (stripping the v prefix)make docker-push for the branch tag and each git tagMakefile with docker-build and docker-push targetsDOCKER_TAG, DOCKER_REGISTRY, DOCKER_REPOSITORY, and IMAGE_NAME environment variablesfetch-depth: 0 to ensure git tags are available