Skip to content

ci: update docker-image.yml #17

ci: update docker-image.yml

ci: update docker-image.yml #17

Workflow file for this run

name: Publish Docker image
on:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ "v*.*.*" ]
# [ workflow_dispatch ]
env:
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: Build the Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker compose build --no-cache --force-rm
test:
name: Test Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Test Docker image
run: docker compose up -d
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: "{{defaultContext}}"
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}