-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (41 loc) · 1.85 KB
/
Copy pathpr-rules-develop.yml
File metadata and controls
48 lines (41 loc) · 1.85 KB
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
name: 'Check PR Rules for Develop'
on:
pull_request_target:
types: [ opened, reopened ]
branches:
- develop
env:
PR_NUMBER: ${{ github.event.number }}
jobs:
pr-rules-develop:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/create-github-app-token@v3
id: cls-python-workflow-token
with:
app-id: ${{ secrets.CLS_PYTHON_WORKFLOW_CLIENT_ID }}
private-key: ${{ secrets.CLS_PYTHON_WORKFLOW_PRIVATE_KEY }}
- uses: actions/checkout@v7
with:
# Full history for timestamps
fetch-depth: 0
token: ${{ steps.cls-python-workflow-token.outputs.token }}
- name: Close Pull Request and Comment if Violating
if: ${{ !contains( github.head_ref, 'feature/') && !contains( github.head_ref, 'bugfix/') && !contains( github.head_ref, 'dependabot/github_actions/') && !contains( github.head_ref, 'main')}}
run: |
gh pr comment ${{ env.PR_NUMBER }} --body ":warning: You can only merge to develop from a feature or a bugfix branch. :warning:"
gh pr close ${{ env.PR_NUMBER }}
env:
GH_TOKEN: ${{ steps.cls-python-workflow-token.outputs.token }}
- name: Fail Job if Violating
if: ${{ !contains( github.head_ref, 'feature/') && !contains( github.head_ref, 'bugfix/') && !contains( github.head_ref, 'dependabot/github_actions/') && !contains( github.head_ref, 'main')}}
run: |
echo "Reason: You can only merge to develop from a feature or a bugfix branch."
exit 1
- name: Succeed Job if not Violating
if: ${{ contains( github.head_ref, 'feature/') || contains( github.head_ref, 'bugfix/') || contains( github.head_ref, 'dependabot/github_actions/') && !contains( github.head_ref, 'main')}}
run: |
exit 0