Skip to content

Publish Docker image #4

Publish Docker image

Publish Docker image #4

name: Publish Docker image
on:
release:
types: [published]
workflow_dispatch:
env:
DOCKERHUB_IMAGE_NAME: shawndengdocker/ibkr_event_daemon
GITHUB_IMAGE_NAME: ghcr.io/shawnden-coder/ibkr_event_daemon
jobs:
push_to_registry:
name: Push Docker image to Docker Hub and GHCR
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Load secret
uses: 1password/load-secrets-action@v2
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
PERSONAL_ACCESS_TOKEN: op://shawndengdev/github_access_token/credential
DOCKER_USERNAME: shawndengdocker
DOCKER_TOKEN: op://shawndengdev/dockerhub/credential
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ env.PERSONAL_ACCESS_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKERHUB_IMAGE_NAME }}
${{ env.GITHUB_IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=ref,event=pr
type=sha,format=short
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}