Skip to content

Need to log into Docker or not? #94

Need to log into Docker or not?

Need to log into Docker or not? #94

Workflow file for this run

name: container-build
on:
push:
branches: [ main ]
env:
REGISTRY: ghcr.io
# Best practice to hard-code your GitHub username below in LOWERCASE.
# Update to your own GitHub username.
IMAGE_NAME: nmagee/fastapi-demo
IMAGE_TAG: 1.${{ github.run_number }} # GITHUB_RUN_NUMBER
DOCKER_BUILDKIT: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Login to Docker
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_TOKEN }}
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
provenance: false
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
ghcr.io/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}