Skip to content

Commit fb5e740

Browse files
authored
Add workflow for pull request draft builds (#138)
1 parent c815556 commit fb5e740

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Deploy Draft
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
dispatch-deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Determine the build branch and draft branch for dispatch.
14+
- name: Determine Dispatch Parameters
15+
run: |
16+
if [ "${{ github.event_name }}" == "pull_request" ]; then
17+
# If this workflow is kicked off by a pull request, build
18+
# a draft using the pull request base branch and PR branch.
19+
build_branch="${{ github.base_ref }}"
20+
draft_branch="${{ github.event.pull_request.head.ref }}"
21+
else
22+
if [ "$(basename ${{ github.event.ref }})" == "stage" ]; then
23+
# This was a merge to stage so kick off a build to update stage draft.
24+
build_branch=stage
25+
draft_branch=stage
26+
else
27+
# Otherwise this is a push to one of the source branches so
28+
# dispatch a build for the main draft to pick up the changes.
29+
build_branch=main
30+
draft_branch=main
31+
fi
32+
fi
33+
echo "build_branch=$build_branch" >> $GITHUB_OUTPUT
34+
echo "draft_branch=$draft_branch" >> $GITHUB_OUTPUT
35+
id: branches
36+
37+
- name: Deploy Draft
38+
uses: convictional/[email protected]
39+
with:
40+
owner: riptano
41+
repo: datastax-docs-site
42+
github_token: ${{ secrets.DISPATCH_GITHUB_TOKEN }}
43+
github_user: ${{ secrets.DISPATCH_GITHUB_USER }}
44+
workflow_file_name: deploy-draft.yml
45+
client_payload: '{ "build_repository": "${{ github.event.repository.full_name }}", "build_branch": "${{ steps.branches.outputs.build_branch }}", "draft_branch": "${{ steps.branches.outputs.draft_branch }}", "pull_request_number": "${{ github.event.pull_request.number }}" }'

0 commit comments

Comments
 (0)