! headers cleaned #4
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 Image Latest | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
build-and-publish-latest: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' # Running this job only for main branch | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: downcase github.repository | |
run: | | |
echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV} | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# - name: Build and push Docker image | |
# uses: docker/build-push-action@v5 | |
# with: | |
# context: . | |
# push: true | |
# tags: ${{ steps.meta.outputs.tags }} | |
# labels: ${{ steps.meta.outputs.labels }} | |
- name: Build and push Docker image Latest | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" |