feat: add guide for retrieving changed files for tags (#955)
This commit is contained in:
parent
0953088baa
commit
f487fc6c7b
50
README.md
50
README.md
@ -403,6 +403,56 @@ See [inputs](#inputs) for more information.
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Get all changed files between the previous tag and the current tag</summary>
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
...
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get Base SHA
|
||||||
|
id: get-base-sha
|
||||||
|
run: |
|
||||||
|
echo "base_sha=$(git rev-parse "$(git tag --sort=-v:refname | head -n 2 | tail -n 1)")" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Get changed files
|
||||||
|
id: changed-files
|
||||||
|
uses: tj-actions/changed-files@v35
|
||||||
|
with:
|
||||||
|
base_sha: ${{ steps.get-base-sha.outputs.base_sha }}
|
||||||
|
|
||||||
|
- name: Get changed files in the .github folder
|
||||||
|
id: changed-files-specific
|
||||||
|
uses: tj-actions/changed-files@v35
|
||||||
|
with:
|
||||||
|
base_sha: ${{ steps.get-base-sha.outputs.base_sha }}
|
||||||
|
files: .github/**
|
||||||
|
|
||||||
|
- name: Run step if any file(s) in the .github folder change
|
||||||
|
if: steps.changed-files-specific.outputs.any_changed == 'true'
|
||||||
|
run: |
|
||||||
|
echo "One or more files in the .github folder has changed."
|
||||||
|
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
See [inputs](#inputs) for more information.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Get all changed files for a repository located in a different path</summary>
|
<summary>Get all changed files for a repository located in a different path</summary>
|
||||||
|
|
||||||
|
@ -8,6 +8,11 @@ EXTRA_ARGS="--no-tags --prune --no-recurse-submodules"
|
|||||||
PREVIOUS_SHA=""
|
PREVIOUS_SHA=""
|
||||||
CURRENT_SHA=""
|
CURRENT_SHA=""
|
||||||
DIFF="..."
|
DIFF="..."
|
||||||
|
IS_TAG="false"
|
||||||
|
|
||||||
|
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
|
||||||
|
IS_TAG="true"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
|
if [[ "$GITHUB_REF" == "refs/tags/"* ]]; then
|
||||||
EXTRA_ARGS="--prune --no-recurse-submodules"
|
EXTRA_ARGS="--prune --no-recurse-submodules"
|
||||||
@ -132,6 +137,10 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
PREVIOUS_SHA=$INPUT_BASE_SHA
|
PREVIOUS_SHA=$INPUT_BASE_SHA
|
||||||
|
|
||||||
|
if [[ "$IS_TAG" == "true" ]]; then
|
||||||
|
TARGET_BRANCH=$(git describe --tags "$PREVIOUS_SHA")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::debug::Target branch $TARGET_BRANCH..."
|
echo "::debug::Target branch $TARGET_BRANCH..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user