Skip to content
Permalink
Browse files

Fix docs builds for pull requests

  • Loading branch information...
dahlia committed May 15, 2019
1 parent f7cbc59 commit abd4ac6068546dfc2d58ea5ddf50e0ee61925e7f
Showing with 41 additions and 3 deletions.
  1. +34 −0 .github/bin/dist-git-checkout.sh
  2. +6 −2 .github/main.workflow
  3. +1 −1 Docs/publish.sh
@@ -0,0 +1,34 @@
#!/bin/ash
# Make the workspace directory to have a pull request's head instead of
# base if it's a pull request.
# Note that this script is intended to be run by GitHub Actions.
set -ev

if [ "$GITHUB_EVENT_NAME" = "" ]; then
{
echo "This script is intended to be run by GitHub Actions."
echo "You can run GitHub Actions locally using \`act':"
echo " https://github.com/nektos/act"
} > /dev/stderr
exit 1
elif [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then
exit 0
fi


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

git_url="$(jq -r '.pull_request.head.repo.git_url' "$GITHUB_EVENT_PATH")"
git_ref="$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH")"
git_sha="$(jq -r '.pull_request.head.sha' "$GITHUB_EVENT_PATH")"

git remote add fork "$git_url"
git fetch fork

git branch -f "$git_ref"
git checkout "$git_ref"
git reset --hard "$git_sha"
@@ -46,7 +46,7 @@ action "docs:status" {
needs = "docs:publish"
args = [
"--repository=\"$GITHUB_REPOSITORY\"",
"--sha=\"$GITHUB_SHA\"",
"--sha=\"$(cat \".git/$(awk '{ print $2 }' .git/HEAD)\")\"",
"--context=docs",
"--description='Libplanet docs generated by DocFX'",
"--state=success",
@@ -65,9 +65,13 @@ action "dist:version" {
args = [".github/bin/dist-version.ps1"]
}

action "dist:git-checkout" {
uses = "dahlia/actions/checkout-pull-request@master"
}

action "dist:pack" {
uses = "docker://mcr.microsoft.com/dotnet/core/sdk:2.2"
needs = "dist:version"
needs = ["dist:version", "dist:git-checkout"]
runs = [".github/bin/dist-pack.sh"]
}

@@ -23,7 +23,7 @@ b64d() {
if [ "$GHPAGES_SSH_KEY" = "" ]; then
{
echo "The environment variable GHPAGES_SSH_KEY is not configured."
echo "Configure GITHUB_TOKEN from GitHub Actions web page."
echo "Configure GHPAGES_SSH_KEY from GitHub Actions web page."
echo "The key has to be also registered as a deploy key of the repository" \
", and be allowed write access."
echo "GHPAGES_SSH_KEY has to contain a base64-encoded private key without" \

0 comments on commit abd4ac6

Please sign in to comment.
You can’t perform that action at this time.