feat(release): push images to Docker Hub #7
Workflow file for this run
This file contains 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: Build and Push Docker Image | |
env: | |
IMAGE_NAME: nodebuilder | |
on: | |
release: | |
types: [ published ] | |
workflow_dispatch: | |
pull_request: | |
branches: [ push_docker_images_test ] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
config: | |
- {container: 'alpine', dockerfile: 'Dockerfile_alpine'} | |
- {container: 'amazon', dockerfile: 'Dockerfile_amazon'} | |
- {container: 'arch', dockerfile: 'Dockerfile_arch'} | |
- {container: 'debian', dockerfile: 'Dockerfile_debian'} | |
- {container: 'fedora', dockerfile: 'Dockerfile_fedora'} | |
- {container: 'manjaro', dockerfile: 'Dockerfile_manjaro'} | |
- {container: 'redhat', dockerfile: 'Dockerfile_redhat'} | |
- {container: 'ubuntu', dockerfile: 'Dockerfile'} | |
- {container: 'opensuse', dockerfile: 'Dockerfile_opensuse'} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract tag name | |
run: | | |
if [[ "${{ github.event_name }}" == "release" ]]; then | |
echo "NODEBUILDER_VERSION=${GITHUB_REF#refs/tags/}" >> "${GITHUB_ENV}" | |
else | |
echo "NODEBUILDER_VERSION=$(git describe --tags --abbrev=0)" >> "${GITHUB_ENV}" | |
fi | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: docker/${{ matrix.config.dockerfile }} | |
push: true | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ matrix.config.container }} | |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ matrix.config.container }}-${{ env.NODEBUILDER_VERSION }} |