CLA signature #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |