|
1 | | -name: On pull request |
2 | | - |
3 | | -on: |
4 | | - pull_request: |
5 | | - branches: |
6 | | - - main |
7 | | - |
8 | | -permissions: write-all |
9 | | - |
10 | | -jobs: |
11 | | - test: |
12 | | - runs-on: ubuntu-latest |
13 | | - |
14 | | - strategy: |
15 | | - matrix: |
16 | | - node-version: |
17 | | - - 20.x |
18 | | - |
19 | | - steps: |
20 | | - - name: Checkouting code... |
21 | | - uses: actions/checkout@v4 |
22 | | - with: |
23 | | - ref: ${{ github.head_ref }} |
24 | | - |
25 | | - - name: Use Node.js ${{ matrix.node-version }} |
26 | | - uses: actions/setup-node@v4 |
27 | | - with: |
28 | | - node-version: ${{ matrix.node-version }} |
29 | | - |
30 | | - - name: NPM install |
31 | | - run: npm install |
32 | | - |
33 | | - - name: NPM test |
34 | | - run: npm run test |
35 | | - |
36 | | - build: |
37 | | - |
38 | | - runs-on: ubuntu-latest |
39 | | - needs: test |
40 | | - |
41 | | - strategy: |
42 | | - matrix: |
43 | | - node-version: |
44 | | - - 20.x |
45 | | - |
46 | | - steps: |
47 | | - - name: Checkouting code... |
48 | | - uses: actions/checkout@v4 |
49 | | - with: |
50 | | - ref: ${{ github.head_ref }} |
51 | | - |
52 | | - - name: Use Node.js ${{ matrix.node-version }} |
53 | | - uses: actions/setup-node@v4 |
54 | | - with: |
55 | | - node-version: ${{ matrix.node-version }} |
56 | | - |
57 | | - - name: NPM install |
58 | | - run: npm install |
59 | | - |
60 | | - - name: NPM build |
61 | | - run: npm run build |
62 | | - |
63 | | - - name: NPM format |
64 | | - run: npm run format |
65 | | - |
66 | | - - name: NPM format check |
67 | | - run: npm run format-check |
68 | | - |
69 | | - - name: Lint |
70 | | - run: npm run lint |
71 | | - |
72 | | - - name: Pack |
73 | | - run: npm run pack |
74 | | - |
75 | | - - name: Uploading build artifact... |
76 | | - uses: actions/upload-artifact@v4 |
77 | | - with: |
78 | | - name: build |
79 | | - path: dist/*.js |
80 | | - |
81 | | - commit_and_push: |
82 | | - |
83 | | - runs-on: ubuntu-latest |
84 | | - name: Commit and push build if needed |
85 | | - needs: build |
86 | | - |
87 | | - steps: |
88 | | - - name: Checkouting code... |
89 | | - uses: actions/checkout@v4 |
90 | | - with: |
91 | | - ref: ${{ github.head_ref }} |
92 | | - |
93 | | - - name: Downloading build artifact.... |
94 | | - uses: actions/download-artifact@v4 |
95 | | - with: |
96 | | - name: build |
97 | | - path: dist/ |
98 | | - |
99 | | - - name: Auto commiting changes... |
100 | | - uses: stefanzweifel/git-auto-commit-action@v5 |
101 | | - with: |
102 | | - commit_message: Automatically builded and updated |
103 | | - file_pattern: dist/*.js |
104 | | - skip_fetch: true |
105 | | - skip_checkout: true |
106 | | - |
107 | | - dependabot: |
108 | | - needs: |
109 | | - - build |
110 | | - - commit_and_push |
111 | | - permissions: |
112 | | - pull-requests: write |
113 | | - contents: write |
114 | | - runs-on: ubuntu-latest |
115 | | - # Checking the actor will prevent your Action run failing on non-Dependabot |
116 | | - # PRs but also ensures that it only does work for Dependabot PRs. |
117 | | - if: ${{ github.actor == 'dependabot[bot]' }} |
118 | | - steps: |
119 | | - # This first step will fail if there's no metadata and so the approval |
120 | | - # will not occur. |
121 | | - - name: Dependabot metadata |
122 | | - id: dependabot-metadata |
123 | | - uses: dependabot/[email protected] |
124 | | - with: |
125 | | - github-token: "${{ secrets.GITHUB_TOKEN }}" |
126 | | - # Here the PR gets approved. |
127 | | - - name: Approve a PR |
128 | | - run: gh pr review --approve "$PR_URL" |
129 | | - env: |
130 | | - PR_URL: ${{ github.event.pull_request.html_url }} |
131 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
132 | | - # Finally, this sets the PR to allow auto-merging for patch and minor |
133 | | - # updates if all checks pass |
134 | | - - name: Enable auto-merge for Dependabot PRs |
135 | | - # if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }} |
136 | | - run: gh pr merge --auto --squash "$PR_URL" |
137 | | - env: |
138 | | - PR_URL: ${{ github.event.pull_request.html_url }} |
139 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 1 | +name: On pull request |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: write-all |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + node-version: |
| 17 | + - 20.x |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkouting code... |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Use Node.js ${{ matrix.node-version }} |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: ${{ matrix.node-version }} |
| 27 | + |
| 28 | + - name: NPM install |
| 29 | + run: npm install |
| 30 | + |
| 31 | + - name: NPM test |
| 32 | + run: npm run test |
| 33 | + |
| 34 | + build: |
| 35 | + |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: test |
| 38 | + |
| 39 | + steps: |
| 40 | + - name: Checkouting code... |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + - name: Use Node.js ${{ matrix.node-version }} |
| 44 | + uses: actions/setup-node@v4 |
| 45 | + with: |
| 46 | + node-version: 20.x |
| 47 | + |
| 48 | + - name: NPM install |
| 49 | + run: npm install |
| 50 | + |
| 51 | + - name: NPM format |
| 52 | + run: npm run format |
| 53 | + |
| 54 | + - name: NPM format check |
| 55 | + run: npm run format-check |
| 56 | + |
| 57 | + - name: Lint |
| 58 | + run: npm run lint |
| 59 | + |
| 60 | + - name: Pack |
| 61 | + run: npm run pack |
| 62 | + |
| 63 | + - name: Uploading build artifact... |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: build |
| 67 | + path: dist/*.* |
| 68 | + |
| 69 | + commit_and_push: |
| 70 | + |
| 71 | + runs-on: ubuntu-latest |
| 72 | + name: Commit and push build if needed |
| 73 | + needs: build |
| 74 | + |
| 75 | + steps: |
| 76 | + - name: Checkouting code... |
| 77 | + uses: actions/checkout@v4 |
| 78 | + |
| 79 | + - name: Downloading build artifact.... |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: build |
| 83 | + path: dist/ |
| 84 | + |
| 85 | + - name: Auto commiting changes... |
| 86 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 87 | + with: |
| 88 | + commit_message: Automatically builded and updated |
| 89 | + file_pattern: dist/*.js dist/*.json |
| 90 | + skip_fetch: true |
| 91 | + skip_checkout: true |
| 92 | + |
| 93 | + dependabot: |
| 94 | + needs: |
| 95 | + - build |
| 96 | + - commit_and_push |
| 97 | + permissions: |
| 98 | + pull-requests: write |
| 99 | + contents: write |
| 100 | + runs-on: ubuntu-latest |
| 101 | + # Checking the actor will prevent your Action run failing on non-Dependabot |
| 102 | + # PRs but also ensures that it only does work for Dependabot PRs. |
| 103 | + if: ${{ github.actor == 'dependabot[bot]' }} |
| 104 | + steps: |
| 105 | + # This first step will fail if there's no metadata and so the approval |
| 106 | + # will not occur. |
| 107 | + - name: Dependabot metadata |
| 108 | + id: dependabot-metadata |
| 109 | + uses: dependabot/[email protected] |
| 110 | + with: |
| 111 | + github-token: "${{ secrets.GITHUB_TOKEN }}" |
| 112 | + # Here the PR gets approved. |
| 113 | + - name: Approve a PR |
| 114 | + run: gh pr review --approve "$PR_URL" |
| 115 | + env: |
| 116 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 117 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 118 | + # Finally, this sets the PR to allow auto-merging for patch and minor |
| 119 | + # updates if all checks pass |
| 120 | + - name: Enable auto-merge for Dependabot PRs |
| 121 | + # if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }} |
| 122 | + run: gh pr merge --auto --squash "$PR_URL" |
| 123 | + env: |
| 124 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 125 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments