Skip to content

Commit fa1e07d

Browse files
authored
Merge pull request #20 from thedadams/refactor-workflows
chore: refactor workflows to be reusable
2 parents 307e978 + 17ebee7 commit fa1e07d

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

.github/workflows/pull_request.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Pull Request
2+
on:
3+
pull_request_target:
4+
types:
5+
- opened
6+
- synchronize
7+
- reopened
8+
- labeled
9+
branches:
10+
- main
11+
paths-ignore:
12+
- README.md
13+
14+
jobs:
15+
check-perms:
16+
if: ${{ !github.event.pull_request.merged }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Get User Permission
20+
id: checkAccess
21+
uses: actions-cool/check-user-permission@v2
22+
with:
23+
require: write
24+
username: ${{ github.triggering_actor }}
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Check User Permission
28+
if: steps.checkAccess.outputs.require-result == 'false'
29+
run: |
30+
echo "${{ github.triggering_actor }} does not have permissions on this repo."
31+
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
32+
echo "Job originally triggered by ${{ github.actor }}"
33+
exit 1
34+
run-tests:
35+
uses: gptscript-ai/node-gptscript/.github/workflows/run_tests.yaml@main
36+
needs: check-perms
37+
with:
38+
git_ref: ${{ github.event.pull_request.head.sha }}
39+
secrets:
40+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

.github/workflows/push_main.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Push Main
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- README.md
8+
9+
jobs:
10+
run-tests:
11+
uses: gptscript-ai/node-gptscript/.github/workflows/run_tests.yaml@main
12+
with:
13+
git_ref: ''
14+
secrets:
15+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

.github/workflows/test.yaml renamed to .github/workflows/run_tests.yaml

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
name: test
1+
name: Run Tests
2+
23
on:
3-
push:
4-
branches:
5-
- main
6-
paths-ignore:
7-
- README.md
8-
pull_request_target:
9-
types:
10-
- labeled
11-
- unlabeled
12-
branches:
13-
- main
14-
paths-ignore:
15-
- README.md
4+
workflow_call:
5+
inputs:
6+
git_ref:
7+
required: true
8+
type: string
9+
secrets:
10+
OPENAI_API_KEY:
11+
required: true
1612

1713
jobs:
1814
check-perms:

0 commit comments

Comments
 (0)