Skip to content

test action right files #1

test action right files

test action right files #1

name: Build and Push Docker Image
# Triggers the workflow when changes are pushed to the main branch or Dockerfile.testing_base_bookworm is updated
on:
push:
branches:
- main # Change this to your target branch if needed
paths:
- 'Dockerfile.testing_base_bookworm'
jobs:
build:
name: Build and Push Dockerfile.testing_base_bookworm
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }} # Use repository name
DOCKERFILE: Dockerfile.testing_base_bookworm
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Set up Docker Buildx (optional but recommended for multi-platform builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build the Docker image from Dockerfile.testing_base_bookworm
- name: Build Docker image
run: |
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:testing_base_bookworm-${{ github.sha }} -f ${{ env.DOCKERFILE }} .
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:testing_base_bookworm-${{ github.sha }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Push the Docker image to GitHub Container Registry
- name: Push Docker image
run: |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:testing_base_bookworm-${{ github.sha }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest