-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
53 lines (48 loc) · 1.92 KB
/
action.yml
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
49
50
51
52
53
name: Add pull request to project
description: GitHub Action to add new pull requests to the Community Contributions GitHub project
inputs:
app_id:
description: 'The ID for a GitHub App, used to generate a token'
required: true
private_key:
description: 'The private key for a GitHub App, used to generate a token'
required: true
runs:
using: composite
steps:
- name: Check if should be added
id: check-if-should-add
shell: bash
env:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
IS_DRAFT: ${{ github.event.pull_request.draft }}
run: |
if [[ $IS_DRAFT == 'true' ]]; then
echo "PR is draft. Skipping."
echo "should_add_to_project=false" >> $GITHUB_OUTPUT
exit 0
fi
# We don't want CMS Squad member PRs to clutter the project board
echo "Author is $PR_AUTHOR"
for ignore_user in 'dependabot[bot]' 'github-actions[bot]' 'GuySartorelli' 'emteknetnz'; do
if [[ $PR_AUTHOR == $ignore_user ]]; then
echo "Author is in CMS Squad or is a bot user. Skipping."
echo "should_add_to_project=false" >> $GITHUB_OUTPUT
exit 0
fi
done
echo "should_add_to_project=true" >> $GITHUB_OUTPUT
- name: Generate token
id: generate-token
if: steps.check-if-should-add.outputs.should_add_to_project == 'true' && github.repository_owner == 'silverstripe'
uses: actions/create-github-app-token@v1
with:
app-id: ${{ inputs.app_id }}
private-key: ${{ inputs.private_key }}
- name: Add to project
if: steps.check-if-should-add.outputs.should_add_to_project == 'true'
uses: actions/[email protected]
with:
# Add to the Community Contributions project
project-url: https://github.com/orgs/silverstripe/projects/4
github-token: ${{ steps.generate-token.outputs.token }}