generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 27
103 lines (87 loc) · 3.17 KB
/
pull_request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: "Pull Request Workflow"
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/checkout@v2.4.0
with:
token: ${{ secrets.ACTION_TOKEN }}
ref: ${{ github.event.pull_request.head.sha }}
- run: npm install
- run: npm run test:badges
- run: npm run package
- uses: stefanzweifel/git-auto-commit-action@v4.11.0
with:
commit_message: "Auto-package action"
# test action works running from the graph
enforce-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
with:
token: ${{ secrets.ACTION_TOKEN }}
ref: ${{ github.event.pull_request.head.ref }}
- id: read-version
run: |
echo "::set-output name=version::$(jq -r ".version" package.json)"
echo "::set-output name=tag::v$(jq -r ".version" package.json)"
- uses: dangoslen/dependabot-changelog-helper@v1
with:
version: ${{ steps.read-version.outputs.tag }}
activationLabel: 'dependabot'
newVersionLineNumber: 4
- uses: stefanzweifel/git-auto-commit-action@v4.11.0
with:
commit_message: "Update changelog"
- id: changelog-enforcer
uses: ./
with:
skipLabels: "skip-changelog"
expectedLatestVersion: ${{ steps.read-version.outputs.tag }}
- 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.tag }}"
path: ./CHANGELOG.md
- id: check_release
run: |
TAG=$(git ls-remote --tags origin | grep ${{ steps.read-version.outputs.tag }} || [[ $? == 1 ]] && echo '')
MISSING=$([[ -z "$TAG" ]] && echo 'true' || echo 'false')
echo ::set-output name=missing::$MISSING
- if: ${{ steps.check_release.outputs.missing }}
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>