Skip to content

re-organize documentation. fix publish-docker-image.yaml workflow #3

re-organize documentation. fix publish-docker-image.yaml workflow

re-organize documentation. fix publish-docker-image.yaml workflow #3

name: "Publish Docker image"
on:
push:
branches:
- main
pull_request: {}
env:
IMAGE_NAME: "my-awesome-app"
permissions:
contents: read
packages: write
jobs:
publish:
name: "Build and publish Docker image"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Login to Docker Hub"
uses: docker/login-action@v3
with:
username: fernandoarteaga
password: ${{ secrets.FERNANDO_DOCKER_HUB_TOKEN }}
- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Extract metadata (tags, labels) for Docker"
id: meta
uses: docker/metadata-action@v5
with:
images: |
fernandoarteaga/${{ env.IMAGE_NAME }}
ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
type=sha
# set latest tag for main branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: "Build and push Docker images"
uses: docker/build-push-action@v5
with:
context: ./my-awesome-app
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}