Skip to content

Commit

Permalink
Merge pull request #10 from im-open/satisfied-conditions
Browse files Browse the repository at this point in the history
Add PR comment if the action contributing guidelines have been met
  • Loading branch information
cbchadb35 authored Apr 3, 2024
2 parents dcc84e1 + dc7a080 commit 342a925
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/reusable-build-and-review-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,46 @@ jobs:
.addRaw(instructionsWithLinks)
.write();
core.setFailed(instructions);
# ----------------------------------------------------
# Add comment if Contributing Guidelines are satisfied
# ----------------------------------------------------
- name: Add comment if contributing guidelines are satisfied
if: env.HAS_CODE_CHANGES == 'true' && env.NEEDS_BUILD_COMMIT == 'false' && env.NEEDS_README_COMMIT == 'false'
uses: actions/github-script@v7
with:
script: |
// Setup vars for the script to use
const hasBuildStep = ${{ env.HAS_BUILD_STEP }};
const contribId = '${{ inputs.readme-contribution-id }}';
const contributionLink = `https://github.com/${{ github.repository }}${contribId}`;
const contributingTitle = contribId.replace('#', '').split('-').map(w => { return w.slice(0, 1).toUpperCase() + w.slice(1) }).join(' ');
const exampleId = '${{ inputs.readme-examples-id }}';
const readmeLink = `${{ github.event.pull_request.head.repo.html_url }}/blob/${{ github.event.pull_request.head.ref }}/${{ env.README }}`;
const readmeExampleLink = `${readmeLink}${exampleId}`;
const readmeExampleTitle = exampleId.replace('#', '').split('-').map(w => { return w.slice(0, 1).toUpperCase() + w.slice(1) }).join(' ');
// Construct the prComment
let prComment = `The action's [${contributingTitle} Guidelines](${contributionLink}) have been met:
- The action's version in the [${readmeExampleTitle}](${readmeExampleLink}) section of [${{ env.README }}](${readmeLink}) has been updated to \`@${{ env.NEXT_VERSION }}\``
if (hasBuildStep){
prComment += `
- The action has been recompiled (if needed) by running the build command from the root of the repository`;
}
// Comment on PR for branches. A fork's GH_TOKEN only has 'read' permission on all scopes so a comment cannot be made.
if (!${{ env.IS_FORK }}) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: prComment
})
}
// Add workflow summary
core.summary.addRaw(prComment).write();

0 comments on commit 342a925

Please sign in to comment.