test action right files #1
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 | |
# 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 |