Skip to content

Add Tangled link to README (#13) #22

Add Tangled link to README (#13)

Add Tangled link to README (#13) #22

name: Publish Docker Image (Docker Hub)
on:
push:
branches:
- master
- main
tags:
- 'v*'
workflow_dispatch:
concurrency:
group: dockerhub-publish-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Check Docker Hub credentials
id: creds
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
if [ -z "$DOCKERHUB_USERNAME" ] || [ -z "$DOCKERHUB_TOKEN" ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::notice::Skipping Docker Hub publish because DOCKERHUB_USERNAME/DOCKERHUB_TOKEN are not set."
else
echo "enabled=true" >> "$GITHUB_OUTPUT"
fi
- name: Checkout
if: steps.creds.outputs.enabled == 'true'
uses: actions/checkout@v4
- name: Set up QEMU
if: steps.creds.outputs.enabled == 'true'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: steps.creds.outputs.enabled == 'true'
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: steps.creds.outputs.enabled == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract Docker metadata
if: steps.creds.outputs.enabled == 'true'
id: meta
uses: docker/metadata-action@v5
with:
images: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/tweets-2-bsky
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=master,enable=${{ github.ref == 'refs/heads/master' }}
type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=sha,prefix=sha-
- name: Build and push
if: steps.creds.outputs.enabled == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max