✨ init commit #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: 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 GitHub Actions / Docker Build and PublishInvalid workflow file
|
||
IMAGE_TAG: ${{ steps.get_image_details.outputs.TAG }} # Use outputs from custom script | ||
env: | ||
# Removed environment variables |