Request #8 #9
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: Forward Download Link to Issue | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
forwardDownloadLinkToIssue: | |
if: github.event.issue.pull_request && contains(github.event.issue.labels.*.name, 'auto-generated') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set env variables | |
run: | | |
echo "DOWNLOAD_LINK=$(jq -r '.DOWNLOAD_LINK' keywords.json)" >> $GITHUB_ENV | |
- name: Forward comment to issue | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const prComment = context.payload.comment.body; | |
if (!prComment.includes(process.env.DOWNLOAD_LINK)) { | |
console.log(`The PR comment does not contain the string "${process.env.DOWNLOAD_LINK}".`); | |
return; | |
} | |
const pr = await github.pulls.get({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
const branchName = pr.data.head.ref; | |
const issueNumber = branchName.split('-')[1].split('/')[0]; | |
github.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
body: `Your data is ready for up to 7 days: ${prComment}` | |
}); |