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`
This commit is contained in:
Christophe Coevoet 2021-01-13 22:06:56 +01:00 committed by GitHub
parent a2d2fe20fd
commit 6ea8ce6cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -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:

View File

@ -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