Skip to content

✨ init commit

✨ init commit #1

name: Docker Build and Publish
on:
push:
branches:
- main
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx (optional)
uses: docker/setup-buildx-action@v3
with: # Optional arguments for Buildx configuration
platforms: linux/amd64,linux/arm64 # Target platforms
buildkitd-flags: --debug # Enable debug flags (optional)
- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login --username "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
env:
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} # Use a secret for secure token storage
- name: Get image details from poetry.toml (custom script)
run: |
# Extract image name and tag from poetry.toml
IMAGE_NAME=$(cat poetry.toml | grep name= | cut -d '=' -f2 | tr -d ' ')
IMAGE_TAG=$(cat poetry.toml | grep version= | cut -d '=' -f2 | tr -d ' ')
# Set outputs for subsequent steps
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/buildx-action@v3 # Use dedicated buildx action
with:
push: true # Push image to registry after build
cache-from: true # Use cached layers (optional)
file: ./Dockerfile # Path to your Dockerfile (optional)
build-args: # Define build arguments
IMAGE_NAME: ${{ steps.get_image_details.outputs.NAME }} # Use outputs from custom script (uppercase for consistency)

Check failure on line 43 in .github/workflows/docker-build-and-push.yml

View workflow run for this annotation

GitHub Actions / Docker Build and Publish

Invalid workflow file

The workflow is not valid. .github/workflows/docker-build-and-push.yml (Line: 43, Col: 13): A mapping was not expected .github/workflows/docker-build-and-push.yml (Line: 46, Col: 5): Unexpected value ''
IMAGE_TAG: ${{ steps.get_image_details.outputs.TAG }} # Use outputs from custom script
env:
# Removed environment variables