Skip to content

Commit

Permalink
Change Actions for pull_request_target
Browse files Browse the repository at this point in the history
  • Loading branch information
mymro committed Jan 22, 2022
1 parent 63ada2c commit 5011dee
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
33 changes: 4 additions & 29 deletions .github/workflows/build.yml
@@ -1,40 +1,15 @@
name: build

on:
push:
pull_request:
workflow_run:
workflows: ["check_style"]
types:
- completed
schedule:
- cron: '0 0 1 * *' # monthly

jobs:

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- run: pip install black
- name: Check Style
run: black . --check
- name: Add comment to pull request if format is incorrect
if: failure()
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please format your code with black version 21.12b0 before commiting changes. See the README for details'
})

build:
needs: black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
32 changes: 32 additions & 0 deletions check_style.yml
@@ -0,0 +1,32 @@
name: check_style

on:
push:
pull_request_target:

jobs:

black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- run: pip install black
- name: Check Style
run: black . --check
- name: Add comment to pull request if format is incorrect
if: failure()
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please format your code with black version 21.12b0 before commiting changes. See the README for details'
})

0 comments on commit 5011dee

Please sign in to comment.