Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a github workflow to automatically build and publish the latest from the main branch to docker hub. #203

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/docker_build_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Push Docker Image

on:
workflow_run:
workflows: ["Run Ubuntu Headless ebook2audiobook"]
types:
- completed
release:
types:
- published # Trigger on release creation

jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event_name == 'release' }} # Trigger if workflow passed and release published

steps:
# Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3

# Log in to Docker Hub or GitHub Container Registry
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Build the Docker image with multiple tags
- name: Build Docker image
run: |
GIT_HASH=$(git rev-parse --short=9 HEAD)
docker build -t ${{ secrets.DOCKER_USERNAME }}/ebook2audiobook:latest_small -t ${{ secrets.DOCKER_USERNAME }}/ebook2audiobook:$GIT_HASH .

# Push the Docker image to the registry
- name: Push Docker image
run: |
GIT_HASH=$(git rev-parse --short=9 HEAD)
docker push ${{ secrets.DOCKER_USERNAME }}/ebook2audiobook:latest_small
docker push ${{ secrets.DOCKER_USERNAME }}/ebook2audiobook:$GIT_HASH