Skip to content

Update docker-publish.yml #2

Update docker-publish.yml

Update docker-publish.yml #2

name: Build and Publish Docker Image
on:
push:
branches:
- main # Change this to your default branch if it's not `main`
pull_request:
branches:
- main
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/my-image:latest # Change this to your Docker image name
file: ./path/to/your/Dockerfile # Adjust if you are using a specific Dockerfile
- name: Docker Compose Build
run: docker-compose -f docker-compose.yml build
- name: Push Docker Compose Service Images
run: |
docker-compose -f docker-compose.yaml push