Releases/v3.7 #855
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: 'pull-request' | |
on: | |
pull_request_target: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- ready_for_review | |
- labeled | |
- unlabeled | |
jobs: | |
# validates that the pull request is trusted | |
verify: | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
VERIFIED_LABEL=${{ contains(github.event.pull_request.labels.*.name, 'verified') }} | |
if [[ ( $VERIFIED_LABEL == 'false' ) ]]; then | |
echo "Pull request is not from a trusted source!" | |
exit 1 | |
fi | |
# unit tests | |
unit-tests: | |
needs: [ verify ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- run: npm install | |
- run: npm run all | |
# test action works running from the graph | |
enforce-changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
token: ${{ secrets.ACTION_TOKEN }} | |
- id: read_version | |
run: | | |
echo "version=$(jq -r ".version" package.json)" >> $GITHUB_OUTPUT | |
echo "tag=v$(jq -r ".version" package.json)" >> $GITHUB_OUTPUT | |
- uses: ./ | |
with: | |
activationLabel: 'dependabot' | |
- id: auto-commit | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: "Updated Changelog" | |
- id: changelog-enforcer | |
# If changes were detected, it would include a changelog | |
# Skip enforcing the changelog and wait for the next commit to trigger the workflow | |
if: steps.auto-commit.outputs.changes_detected == 'false' | |
uses: dangoslen/changelog-enforcer@v3 | |
with: | |
expectedLatestVersion: ${{ steps.read_version.outputs.version }} | |
- if: failure() | |
uses: unsplash/comment-on-pr@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
check_for_duplicate_msg: true | |
msg: | | |
Hey @${{ github.event.pull_request.user.login }}, the Changelog Enforcer failed. Can you take a look at the error below and correct it? Thanks! | |
``` | |
${{ steps.changelog-enforcer.outputs.errorMessage }} | |
``` | |
- id: changelog_reader | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
version: ${{ steps.read_version.outputs.version }} | |
path: ./CHANGELOG.md | |
- id: check_release | |
run: | | |
TAG=$(git ls-remote --tags origin | grep ${{ steps.read_version.outputs.tag }} | cat ) | |
MISSING=$([[ -z "$TAG" ]] && echo 'true' || echo 'false') | |
echo "missing=$MISSING" >> $GITHUB_OUTPUT | |
- if: ${{ steps.check_release.outputs.missing == 'true' }} | |
uses: unsplash/comment-on-pr@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
check_for_duplicate_msg: true | |
msg: | | |
<details> | |
<summary>Preview of Release Notes to be Created</summary> | |
${{ steps.changelog_reader.outputs.changes }} | |
</details> |