-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add action of version update and add it to workflow
Signed-off-by: jparisu <[email protected]>
- Loading branch information
jparisu
committed
May 10, 2023
1 parent
4f2abfe
commit 22a1e54
Showing
3 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: check_version_update | ||
description: Check if version file has been updated with the change in the repository | ||
|
||
inputs: | ||
|
||
version-file-path: | ||
description: The path to the file to check for changes from repository base | ||
required: true | ||
default: versions.md | ||
|
||
head-ref: | ||
description: Git reference to compare file | ||
required: false | ||
default: ${GITHUB_HEAD_REF} | ||
|
||
base-ref: | ||
description: Git reference to compare against | ||
required: false | ||
default: ${GITHUB_BASE_REF} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
|
||
- name: Sync repository | ||
uses: eProsima/eProsima-CI/external/checkout@main | ||
with: | ||
path: ${{ github.workspace }} | ||
|
||
- name: Fetch all branches and tags | ||
uses: eProsima/eProsima-CI/ubuntu/git_fetch_all@main | ||
with: | ||
workspace: ${{ github.workspace }} | ||
|
||
- name: Get diff file of version file | ||
id: git-diff | ||
uses: eProsima/eProsima-CI/ubuntu/git_diff@main | ||
with: | ||
file-path: ${{ github.workspace }}/${{ inputs.version-file-path }} | ||
|
||
- name: Check if file change | ||
if: ${{ steps.git-diff.outputs.have-changes == 'false' }} | ||
run: | | ||
echo "Version file ${{ inputs.version-file-path }} has not been updated." | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: git_diff | ||
description: Check whether a file in a repository has changed and return diff file | ||
|
||
inputs: | ||
|
||
file-path: | ||
description: The path to the file to check for changes | ||
required: true | ||
|
||
head-ref: | ||
description: Git reference to compare file | ||
required: false | ||
default: ${GITHUB_HEAD_REF} | ||
|
||
base-ref: | ||
description: Git reference to compare against | ||
required: false | ||
default: ${GITHUB_BASE_REF} | ||
|
||
diff-args: | ||
description: Additional arguments to pass to the git diff command | ||
required: false | ||
default: '' | ||
|
||
result-file: | ||
description: Additional arguments to pass to the git diff command | ||
required: false | ||
default: '${{ github.workspace }}/git.diff' | ||
|
||
outputs: | ||
|
||
diff-file-result: | ||
description: The path to the file containing the diff, if changes were detected | ||
|
||
have-changes: | ||
description: Whether there have been changes in such file | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
|
||
- name: get_git_diff_files | ||
shell: bash | ||
run: | | ||
echo "::group::Get git modifications of file ${{ inputs.file-path }}"" | ||
if git diff --name-only "${{ inputs.base-ref }}" "${{ inputs.head-ref }}" ${{ inputs.diff-args }} | grep -q "${{ inputs.file-path }}"; then | ||
git diff "${{ inputs.base-ref }}" "${{ inputs.head-ref }}" ${{ inputs.diff-args }} "${{ inputs.file-path }}" > "${{ inputs.result-file }}" | ||
echo "::set-output name=diff-file-result::$(cat ${{ inputs.result-file }})" | ||
echo "::set-output name=have-changes::true" | ||
else | ||
echo "::set-output name=have-changes::false" | ||
fi | ||
echo "::endgroup::" |