Skip to content

Commit

Permalink
Add workflow_dispatch event trigger for PR images (tursodatabase#1306)
Browse files Browse the repository at this point in the history
  • Loading branch information
avinassh authored Apr 12, 2024
1 parent 15fe600 commit 7badc6d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/server-pr-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
name: libsql server pull request Docker image

on:
workflow_dispatch:
pull_request:
branches: ["main"]
branches: [ "main" ]

env:
REGISTRY: ghcr.io
Expand All @@ -14,8 +15,17 @@ env:
jobs:
# docker image build and upload to ghcr
build-and-push-image:
# run this job only if the pull request is from the same repository
if: github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.body && contains(github.event.pull_request.body, '+build')
# run this job if either:
# 1. The pull request is from the same repository and contains '+build' in the body
# 2. The workflow is manually triggered (workflow_dispatch event)
if: >
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.body &&
contains(github.event.pull_request.body, '+build')
) ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -46,7 +56,7 @@ jobs:
- name: Get short SHA
id: get-short-sha
run: |
SHA="$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-7)"
SHA="$(echo ${GITHUB_SHA::7})"
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
Expand Down

0 comments on commit 7badc6d

Please sign in to comment.