CheckPullRequest #5
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
name: Check Pull Request | |
run-name: CheckPullRequest | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
branches: main | |
concurrency: | |
group: 'pullrequest' | |
cancel-in-progress: true | |
jobs: | |
paths-filter: | |
name: Filter out non code changes | |
runs-on: ubuntu-latest | |
outputs: | |
code-changed: ${{ steps.filter.outputs.src }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Filter Changed Files | |
uses: AurorNZ/paths-filter@v4 | |
id: filter | |
with: | |
filters: | | |
src: | |
- 'src/**/*' | |
- '!src/**/*.test.*' | |
check-version: | |
needs: paths-filter | |
if: needs.paths-filter.outputs.code-changed == 'true' | |
name: Version number was bumped | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Get New Version | |
run: | | |
new_version=$(npm pkg get version | xargs) | |
echo "NEW=${new_version}" >> $GITHUB_ENV | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Get Main Version | |
run: | | |
main_version=$(npm pkg get version | xargs) | |
echo "MAIN=${main_version}" >> $GITHUB_ENV | |
- name: Compare Versions | |
run: | | |
if [[ ${{ env.NEW }} == ${{ env.MAIN }} ]]; then | |
exit 1 | |
fi | |
- name: Post PR Comment | |
if: failure() | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message: Please bump the version in package.json! | |
refresh-message-position: true | |
allow-repeats: true | |
check-changelog: | |
needs: paths-filter | |
if: needs.paths-filter.outputs.code-changed == 'true' | |
name: Changelog was updated | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v42 | |
- name: List all changed files | |
env: | |
ALL_CHANGED_FILES: ${{ steps.check-changelog.outputs.all_changed_files }} | |
run: | | |
for file in ${ALL_CHANGED_FILES}; do | |
echo "$file was changed" | |
done | |
- name: Post PR Comment | |
if: failure() | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message: Please add details in the CHANGELOG.md! | |
refresh-message-position: true | |
allow-repeats: true |