Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update readme #916

Merged
merged 9 commits into from Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Expand Up @@ -953,7 +953,7 @@ jobs:
bash
- name: Run changed-files with custom sha
id: changed-files-custom-sha
if: github.event_name == 'pull_request' && github.event.action != 'closed'
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && github.event.action != 'closed'
uses: ./
with:
sha: ${{ github.event.pull_request.head.sha }}
Expand All @@ -966,21 +966,21 @@ jobs:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
if: github.event_name == 'pull_request' && matrix.fetch-depth == 0
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && matrix.fetch-depth == 0
- uses: nrwl/nx-set-shas@v3
id: last_successful_commit
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && github.event.action != 'closed' && matrix.fetch-depth == 0
with:
main-branch-name: ${{ steps.branch-name.outputs.base_ref_branch }}
workflow-id: 'test.yml'
- name: Run changed-files with a custom base sha
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && github.event.action != 'closed' && matrix.fetch-depth == 0
id: changed-files-custom-base-sha
uses: ./
with:
base_sha: ${{ steps.last_successful_commit.outputs.base }}
- name: Show output
if: github.event_name == 'pull_request' && github.event.action != 'closed' && matrix.fetch-depth == 0
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_review') && github.event.action != 'closed' && matrix.fetch-depth == 0
run: |
echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}'
shell:
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -188,6 +188,7 @@ Support this project with a :star:

<!-- AUTO-DOC-INPUT:END -->


## Examples

<details>
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -183,8 +183,8 @@ runs:
GITHUB_REF: ${{ github.ref }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_WORKSPACE: ${{ github.workspace }}
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
GITHUB_EVENT_HEAD_REPO_FORK: ${{ github.event.pull_request.head.repo.fork }}
GITHUB_EVENT_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_EVENT_PULL_REQUEST_BASE_REF: ${{ github.event.pull_request.base.ref }}
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ${{ github.event.pull_request.head.ref }}
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }}
Expand Down
16 changes: 7 additions & 9 deletions diff-sha.sh
Expand Up @@ -13,7 +13,7 @@ if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
EXTRA_ARGS="--prune --no-recurse-submodules"
fi

if [[ -z $GITHUB_BASE_REF || "$GITHUB_EVENT_HEAD_REPO_FORK" == "true" ]]; then
if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF || "$GITHUB_EVENT_HEAD_REPO_FORK" == "true" ]]; then
DIFF=".."
fi

Expand Down Expand Up @@ -50,17 +50,15 @@ else
echo "Valid git version found: ($GIT_VERSION)"
fi

echo "Base Ref: $GITHUB_BASE_REF"

if [[ -z $GITHUB_BASE_REF ]]; then
if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then
echo "Running on a push event..."
TARGET_BRANCH=$GITHUB_REFNAME
CURRENT_BRANCH=$TARGET_BRANCH

echo "Fetching remote refs..."

# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null 2>&1
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null

echo "::debug::Getting HEAD SHA..."
if [[ -n "$INPUT_UNTIL" ]]; then
Expand Down Expand Up @@ -152,16 +150,16 @@ if [[ -z $GITHUB_BASE_REF ]]; then
fi
else
echo "Running on a pull request event..."
TARGET_BRANCH=$GITHUB_BASE_REF
CURRENT_BRANCH=$GITHUB_HEAD_REF
TARGET_BRANCH=$GITHUB_EVENT_PULL_REQUEST_BASE_REF
CURRENT_BRANCH=$GITHUB_EVENT_PULL_REQUEST_HEAD_REF

if [[ "$INPUT_SINCE_LAST_REMOTE_COMMIT" == "true" ]]; then
TARGET_BRANCH=$CURRENT_BRANCH
fi

echo "Fetching remote refs..."
# shellcheck disable=SC2086
git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null 2>&1
git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null

echo "::debug::Getting HEAD SHA..."
if [[ -n "$INPUT_UNTIL" ]]; then
Expand Down Expand Up @@ -201,7 +199,7 @@ else
else
echo "::debug::Fetching remote target branch..."
# shellcheck disable=SC2086
git fetch -u --progress $EXTRA_ARGS --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null 2>&1
git fetch -u --progress $EXTRA_ARGS --depth="$INPUT_FETCH_DEPTH" origin +refs/heads/"$TARGET_BRANCH":refs/remotes/origin/"$TARGET_BRANCH" 1>/dev/null

git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 || true

Expand Down