-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (55 loc) · 2.19 KB
/
cla-signature.yaml
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
54
55
56
57
name: CLA signature
on:
issues:
types: [opened]
jobs:
cla:
if: ${{ contains(github.event.issue.body, '[X] I accept and sign the contributor license agreement') }}
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
steps:
- uses: actions/checkout@v2
- name: Adding user to contributors
run: |
echo Signature by ${{ github.event.issue.user.login }}
git clone https://github.com/rxn4chemistry/clabot-config.git --branch main --single-branch clabot-config-main
cd clabot-config-main
previous_commit_hash=$(git rev-parse HEAD | cut -c 1-8)
echo $(jq '.contributors |= (. + ["${{ github.event.issue.user.login }}"] | unique)' .clabot) > .clabot
echo Updated .clabot:
echo $(cat .clabot)
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .clabot
git commit -m "chore: adding ${{ github.event.issue.user.login }} as contributor." -a || true
if [ "$previous_commit_hash" != "$(git rev-parse HEAD | cut -c 1-8)" ]; then
echo "signing_commit_hash=$(git rev-parse HEAD | cut -c 1-8)" >> $GITHUB_ENV
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: main
directory: clabot-config-main
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Mark signature in the issue
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
with:
add-labels: cla-signed
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Close issue (existing contributor)
uses: peter-evans/close-issue@v1
if: ${{ env.signing_commit_hash == '' }}
with:
comment: |
Contributor was added already.
- name: Close issue (new contributor)
uses: peter-evans/close-issue@v1
if: ${{ env.signing_commit_hash != '' }}
with:
comment: |
Contributor was added: ${{ env.signing_commit_hash }}.
- name: Show issue url
run: |
echo "Issue: ${{ github.event.issue.html_url }}"