Skip to content

Commit

Permalink
Create docker-image.yml
Browse files Browse the repository at this point in the history
Create automated CI/CD for scriptorium docker image
  • Loading branch information
KagemniKarimu authored Jan 9, 2025
1 parent 5822006 commit 9a72ec2
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Docker Build and Push

on:
push:
branches: [ "main" ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

jobs:
build-and-push:
# Only run if we have secrets for pushing or if it's a PR from the main repo
if: |
secrets.DOCKERHUB_TOKEN ||
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest

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

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
if: secrets.DOCKERHUB_TOKEN
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: ${{ secrets.DOCKERHUB_TOKEN != '' }}
tags: |
kagemnikarimu/scriptorium:latest
kagemnikarimu/scriptorium:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 9a72ec2

Please sign in to comment.