Skip to content

Commit

Permalink
Merge pull request #15 from thedadams/refactor-workflows
Browse files Browse the repository at this point in the history
chore: refactor workflows to be reusable
  • Loading branch information
thedadams authored Apr 24, 2024
2 parents 6680469 + dae1888 commit 51b4f39
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 14 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Pull Request
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- labeled
branches:
- main
paths-ignore:
- README.md

jobs:
check-perms:
if: ${{ !github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1
run-tests:
uses: gptscript-ai/py-gptscript/.github/workflows/run_tests.yaml@main
needs: check-perms
with:
git_ref: ${{ github.event.pull_request.head.sha }}
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
15 changes: 15 additions & 0 deletions .github/workflows/push_main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Push Main
on:
push:
branches:
- main
paths-ignore:
- README.md

jobs:
run-tests:
uses: gptscript-ai/py-gptscript/.github/workflows/run_tests.yaml@main
with:
git_ref: ''
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
24 changes: 10 additions & 14 deletions .github/workflows/test.yaml → .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
name: test
name: Run Tests

on:
push:
branches:
- main
paths-ignore:
- README.md
pull_request_target:
types:
- labeled
- unlabeled
branches:
- main
paths-ignore:
- README.md
workflow_call:
inputs:
git_ref:
required: true
type: string
secrets:
OPENAI_API_KEY:
required: true

jobs:
check-perms:
Expand Down

0 comments on commit 51b4f39

Please sign in to comment.