Skip to content

Commit

Permalink
Build docs for pull requests as well
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed May 14, 2019
1 parent 7c03a0b commit cf87d88
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/main.workflow
Expand Up @@ -3,6 +3,11 @@ workflow "push" {
resolves = ["dist:nuget", "dist:github-release", "docs:status"]
}

workflow "pull request" {
on = "pull_request"
resolves = ["docs:status"]
}

workflow "everyday" {
on = "schedule(59 14 * * *)"
resolves = ["dist:nuget"]
Expand Down
18 changes: 16 additions & 2 deletions Docs/publish.sh
Expand Up @@ -32,6 +32,21 @@ if [ "$GHPAGES_SSH_KEY" = "" ]; then
exit 0
fi

if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
if ! command -v jq > /dev/null; then
wget -O /usr/local/bin/jq \
https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64
chmod +x /usr/local/bin/jq
fi
pr_number="$(jq '.pull_request.number' "$GITHUB_EVENT_PATH")"
slug="pulls/$pr_number"
else
slug="$(echo -n "$GITHUB_REF" | sed -e 's/^refs\/\(heads\|tags\)\///g')"
fi
[ "$slug" != "" ]

echo "Slug: $slug" > /dev/stderr

echo "$GHPAGES_SSH_KEY" | b64d > /tmp/github_id
chmod 600 /tmp/github_id
export GIT_SSH_COMMAND='ssh -i /tmp/github_id -o "StrictHostKeyChecking no"'
Expand All @@ -44,9 +59,8 @@ for _ in 1 2 3; do
git -C /tmp/gh-pages config user.name "$(git log -n1 --format=%cn)"
git -C /tmp/gh-pages config user.email "$(git log -n1 --format=%ce)"

slug="$(echo -n "$GITHUB_REF" | sed -e 's/^refs\/\(heads\|tags\)\///g')"
[ "$slug" != "" ]
rm -rf "/tmp/gh-pages/$slug"
mkdir -p "/tmp/gh-pages/$(dirname "$slug")"
cp -r Docs/_site "/tmp/gh-pages/$slug"
git -C /tmp/gh-pages add "/tmp/gh-pages/$slug"

Expand Down

0 comments on commit cf87d88

Please sign in to comment.