diff --git a/check-cla/action.yml b/check-cla/action.yml index b1f88ac2..186a8514 100644 --- a/check-cla/action.yml +++ b/check-cla/action.yml @@ -73,16 +73,18 @@ runs: description: Checking conda CLA... state: pending - # has_signed - - name: Check if current actor has signed + # number, contributor, url, has_signed + - name: Collect PR metadata uses: actions/github-script@v6 - id: contributors + id: metadata with: github-token: ${{ inputs.token }} script: | - const { owner, repo } = context.issue; + const { owner, repo, number } = context.issue; core.debug(`owner: ${owner}`); core.debug(`repo: ${repo}`); + core.setOutput('number', number); + core.debug(`number: ${number}`); const { content, encoding } = (await github.rest.repos.getContent({ owner: owner, @@ -94,14 +96,16 @@ runs: ).contributors; core.debug(`contributors: ${contributors}`); - const creator = ( - context.payload.issue - || context.payload.pull_request - || context.payload - ).user.login; - core.debug(`creator: ${creator}`); + const payload = context.payload.issue || context.payload.pull_request || context.payload; + const contributor = payload.user.login; + core.setOutput('contributor', contributor); + core.debug(`contributor: ${contributor}`); + + const url = payload.user.html_url; + core.setOutput('url', url); + core.debug(`url: ${url}`); - const has_signed = contributors.includes(creator); + const has_signed = contributors.includes(contributor); core.setOutput('has_signed', has_signed); core.debug(`has_signed: ${has_signed}`); @@ -136,7 +140,7 @@ runs: path = Path("${{ inputs.cla_path }}") signees = json.loads(path.read_text()) - signees["contributors"].append("${{ github.actor }}") + signees["contributors"].append("${{ steps.metadata.outputs.contributor }}") signees["contributors"].sort() path.write_text(json.dumps(signees, indent=2)) @@ -147,23 +151,23 @@ runs: with: push-to-fork: ${{ inputs.cla_fork }} token: ${{ inputs.cla_token }} - branch: cla-${{ github.actor }} + branch: cla-${{ steps.metadata.outputs.contributor }} delete-branch: true - commit-message: Adding CLA singee ${{ github.actor }} + commit-message: Adding CLA singee ${{ steps.metadata.outputs.contributor }} author: ${{ inputs.cla_author }} committer: ${{ inputs.cla_author }} - title: Adding CLA singee ${{ github.actor }} + title: Adding CLA singee ${{ steps.metadata.outputs.contributor }} body: | - Adding CLA signee @${{ github.actor }} + Adding CLA signee @${{ steps.metadata.outputs.contributor }} - Xref ${{ (github.event.issue || github.event.pull_request || github.event).html_url }} + Xref ${{ steps.metadata.outputs.url }} # create sticky comment if not signed - name: Create comment uses: marocchino/sticky-pull-request-comment@v2 if: steps.contributors.outputs.has_signed == 'false' with: - number: ${{ (github.event.issue || github.event.pull_request || github.event).number }} + number: ${{ steps.metadata.outputs.number }} # GitHub flavored markdown reinvents how paragraphs work, adjoined lines of text are not # concatenated so instead we rely on YAML multi-line + extra newlines message: >- @@ -171,7 +175,7 @@ runs: We require contributors to sign our [Contributor License Agreement][cla] and we don't - have one on file for @${{ (github.event.issue || github.event.pull_request || github.event).user.login }}. + have one on file for @${{ steps.metadata.outputs.contributor }}. In order for us to review and merge your code, please e-sign the