From 5ab58aa73ed422481badc9fa4f743048b178af5e Mon Sep 17 00:00:00 2001 From: David Byrne Date: Sun, 8 Mar 2020 20:28:14 +0000 Subject: [PATCH] Use custom workspace for running action in There's been a few issues with Jekyll-Diff-Action using the default `/github/workspace` directory to run in. That's mounted in read only mode, so any command that tried modify it failed (see PR #1 and issue #2). To get away from all this, this PR adds an initial step to the diff script to create our own workspace with the appropriate permissions. --- jekyll_diff.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/jekyll_diff.sh b/jekyll_diff.sh index 3af99b7..0f9efb2 100755 --- a/jekyll_diff.sh +++ b/jekyll_diff.sh @@ -6,6 +6,19 @@ set -e # stop executing after error echo "Starting Jekyll diff script" +#################################################### +# Create workspace for Jekyll Diff Action +#################################################### + +mkdir /jekyll-diff-action +mkdir /jekyll-diff-action/new +mkdir /jekyll-diff-action/old +mkdir /jekyll-diff-action/workspace +cp --archive /github/workspace/. /jekyll-diff-action/workspace +chmod -R a+w /jekyll-diff-action +cd /jekyll-diff-action/workspace + + #################################################### # Determine whether it's a PR or Commit #################################################### @@ -25,13 +38,10 @@ fi # Build both site versions and determine diff #################################################### -cd /github/workspace -mkdir -p .jekyll-cache # workaround for https://github.com/jekyll/jekyll/issues/7591 - -jekyll build --trace --destination /tmp/new/ +jekyll build --trace --destination /jekyll-diff-action/new/ git checkout $common_ancestor_sha -jekyll build --trace --destination /tmp/old -diff="$(diff --recursive --new-file --unified=0 /tmp/old /tmp/new || true)" # 'or true' because a non-identical diff outputs 1 as the exit status +jekyll build --trace --destination /jekyll-diff-action/old +diff="$(diff --recursive --new-file --unified=0 /jekyll-diff-action/old /jekyll-diff-action/new || true)" # 'or true' because a non-identical diff outputs 1 as the exit status ####################################################