From 6ea8ce6cf9c45a33f0735a4a8486b08af4c551d6 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 13 Jan 2021 22:06:56 +0100 Subject: [PATCH] Fix the CI to use a PR version of sass-spec (#1201) The previous implementation contained 2 mistakes: - there was a mismatch between names of env variables in the workflow config and in the script - the `github.base_ref` property in github actions contains a branch name, not a full git ref like `github.ref` --- .github/workflows/ci.yml | 2 +- tool/github-action/sass-spec-ref.sh | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3e1550c..ce6e5df4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: git -C sass-spec checkout FETCH_HEAD env: PR_BRANCH: "${{ github.base_ref }}" - CURRENT_BRANCH: "${{ github.ref }}" + CURRENT_REF: "${{ github.ref }}" PR_BODY: "${{ github.event.pull_request.body }}" - uses: ruby/setup-ruby@v1 with: diff --git a/tool/github-action/sass-spec-ref.sh b/tool/github-action/sass-spec-ref.sh index 654f77c2..192d5e25 100755 --- a/tool/github-action/sass-spec-ref.sh +++ b/tool/github-action/sass-spec-ref.sh @@ -8,15 +8,21 @@ # sass-spec pull request, we'll run against the latter rather than sass-spec # master. -GITHUB_REF=${PR_REF:-$CURRENT_REF} -if [[ "$GITHUB_REF" == refs/heads/feature.* ]]; then - default="${GITHUB_REF:11}" +if [ -z "$PR_BRANCH" ]; then + # Remove the "refs/heads/" prefix + current_branch="${CURRENT_REF:11}" +else + current_branch="$PR_BRANCH" +fi + +if [[ "$current_branch" == feature.* ]]; then + default="$current_branch" else default=master fi -# We don't have a PR_REF so we are not in a pull request -if [ "$GITHUB_REF" == "$CURRENT_REF" ]; then +# We don't have a PR_BRANCH so we are not in a pull request +if [ -z "$PR_BRANCH" ]; then >&2 echo "Ref: $default." echo "$default" exit 0