Create docker-image.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | ||
Check failure on line 13 in .github/workflows/docker-image.yml
|
||
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 |