Add custom source sha (#126)

Co-authored-by: Tonye Jack <jtonye@ymail.com>
This commit is contained in:
Krasimir Nikolov 2021-07-14 23:57:17 +03:00 committed by GitHub
parent b4b0cdd1b5
commit 53afe7a5b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -130,3 +130,13 @@ jobs:
echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}" echo "${{ toJSON(steps.changed-files-specific-comma.outputs) }}"
shell: shell:
bash bash
- name: Run changed-files with custom sha
id: changed-files-custom-sha
uses: ./
with:
sha: ${{ github.event.pull_request.head.sha }}
- name: Show output
run: |
echo "${{ toJSON(steps.changed-files-custom-sha.outputs) }}"
shell:
bash

View File

@ -149,6 +149,11 @@ jobs:
if: steps.changed-files-specific.outputs.any_changed == 'true' if: steps.changed-files-specific.outputs.any_changed == 'true'
run: | run: |
echo "One or more files listed above has changed." echo "One or more files listed above has changed."
- name: Use a different commit SHA as the base
id: changed-files-comma
uses: tj-actions/changed-files@v8.4
with:
sha: ${{ github.event.pull_request.head.sha }}
``` ```

View File

@ -14,6 +14,10 @@ inputs:
description: 'Check for changes using only this list of files (Defaults to the entire repo)' description: 'Check for changes using only this list of files (Defaults to the entire repo)'
required: false required: false
default: "" default: ""
sha:
description: 'Specify a different commit SHA to be used for comparing changes'
required: true
default: ${{ github.sha }}
outputs: outputs:
added_files: added_files:
@ -58,11 +62,11 @@ runs:
id: changed-files id: changed-files
shell: bash shell: bash
env: env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_BASE_REF: ${{ github.base_ref }} GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_REPOSITORY: ${{ github.repository }}
# INPUT_<VARIABLE_NAME> is not available in Composite run steps # INPUT_<VARIABLE_NAME> is not available in Composite run steps
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
INPUT_SHA: ${{ inputs.sha }}
INPUT_TOKEN: ${{ inputs.token }} INPUT_TOKEN: ${{ inputs.token }}
INPUT_FILES: ${{ inputs.files }} INPUT_FILES: ${{ inputs.files }}
INPUT_SEPARATOR: ${{ inputs.separator }} INPUT_SEPARATOR: ${{ inputs.separator }}

View File

@ -8,10 +8,10 @@ git remote set-url origin "https://${INPUT_TOKEN}@github.com/${GITHUB_REPOSITORY
echo "Getting HEAD info..." echo "Getting HEAD info..."
if [[ -z $GITHUB_SHA ]]; then if [[ -z $INPUT_SHA ]]; then
CURR_SHA=$(git rev-parse HEAD 2>&1) && exit_status=$? || exit_status=$? CURR_SHA=$(git rev-parse HEAD 2>&1) && exit_status=$? || exit_status=$?
else else
CURR_SHA=$GITHUB_SHA CURR_SHA=$INPUT_SHA
fi fi
if [[ $exit_status -ne 0 ]]; then if [[ $exit_status -ne 0 ]]; then