diff --git a/.github/actions/tools/exit-code/action.yml b/.github/actions/tools/exit-code/action.yml index 0f9ff16..78282dd 100644 --- a/.github/actions/tools/exit-code/action.yml +++ b/.github/actions/tools/exit-code/action.yml @@ -44,4 +44,9 @@ runs: message: ${{ steps.createMessage.outputs.result }} - shell: cmd + if: ${{ runner.os == 'Windows' }} + run: exit ${{ inputs.code }} + + - shell: bash + if: ${{ runner.os != 'Windows' }} run: exit ${{ inputs.code }} diff --git a/.github/workflows/changelog-changed.yml b/.github/workflows/changelog-changed.yml new file mode 100644 index 0000000..dc1c135 --- /dev/null +++ b/.github/workflows/changelog-changed.yml @@ -0,0 +1,77 @@ +# This workflow ensures that a change was made to the changelog +--- +name: Changelog Changed +run-name: >- + ${{ + format( + '{0} - Changelog Changed{1}', + github.event_name == 'pull_request' + && format('PR#{0}{1}',github.event.number, github.event.pull_request.draft && ' [DRAFT]' || '') + || format('Push [{0}]', github.ref_name), + github.event_name == 'pull_request' + && format(' - [{0}-to-{1}]', github.event.pull_request.head.ref, github.event.pull_request.base.ref) + || '' + ) + }} + +on: + pull_request: + branches: + - main + - develop + types: + - opened + - reopened + - synchronize + - ready_for_review + # Trigger if target branch was changed to a trunk + pull_request_target: + types: + - edited + branches: + - main + - develop + +concurrency: + group: Changelog-${{ github.event.pull_request.head.ref }}-to-${{ github.event.pull_request.base.ref }} + cancel-in-progress: true + +jobs: + checkForChangesToChangelog: + name: Changelog Changed + permissions: + contents: read # Read access to code and content in the repository + pull-requests: read # Read access to pull request metadata for the event + checks: write # Write access to report check results + runs-on: ubuntu-latest + if: ${{ !github.event.pull_request.draft }} + + steps: + # Checkout pull request branch + - name: ${{ format('Checkout [{0}]', github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name) }} + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + token: ${{ secrets.TJC_TOKEN || secrets.GITHUB_TOKEN }} + + # Check for Changes in Changelog + - name: Check for Changes to Changelog + id: getChanges + uses: tj-actions/changed-files@v45.0.3 + with: + files: CHANGELOG.md + + # Report Success + - name: Success - Changelog Changed + if: steps.getChanges.outputs.any_modified == 'true' + uses: ./.github/actions/tools/annotation/notice + with: + message: "[Success] Changelog Changed" + + # Report Failure + - name: Failure - Changelog Not Changed + if: steps.getChanges.outputs.any_modified != 'true' + uses: ./.github/actions/tools/exit-code + with: + code: 5 + message: "Changelog Not Changed" diff --git a/.jscpd.json b/.jscpd.json index 3806512..4db0004 100644 --- a/.jscpd.json +++ b/.jscpd.json @@ -1,4 +1,4 @@ { "threshold": 0.1, - "ignore": ["*.Tests/**"] + "ignore": ["*.Tests/**", ".github/**"] } diff --git a/CHANGELOG.md b/CHANGELOG.md index 049601e..4466984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Changelog changed check workflow for pr's + ## [0.6.2] - 2024-11-10 ### Changed diff --git a/README.md b/README.md index cb5ff9f..e3d5387 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,6 @@ [![License](https://img.shields.io/github/license/TJC-Tools/TJC.StringExtensions.svg)](LICENSE) [![codecov](https://codecov.io/gh/TJC-Tools/TJC.StringExtensions/graph/badge.svg?token=RJ4DWNQ7S5)](https://codecov.io/gh/TJC-Tools/TJC.StringExtensions) + +## Documentation +- [Changelog](CHANGELOG.md)