Scripts: add automatic comment on pull requests
This commit is contained in:
parent
58cdaedc6a
commit
d831dbc5b4
1 changed files with 11 additions and 7 deletions
|
@ -66,16 +66,20 @@ jobs:
|
|||
- name: unzipping remote file
|
||||
run: ssh hetzner "cd /root/staging && rm -rf ${{ github.ref_name }} && unzip ${{ github.ref_name }}.zip && rm -rf /root/public/${{ github.ref_name }} && mv /root/staging/${{ github.ref_name }}/ /root/public/ && rm ${{ github.ref_name }}.zip"
|
||||
|
||||
- name: Extract PR number
|
||||
run: echo "PR_NUMBER=$(echo $FORGEJO_REF_NAME | cut -d'/' -f3)" >> $FORGEJO_ENV
|
||||
|
||||
- name: add comment to PR
|
||||
if: env.PR_NUMBER != ''
|
||||
- name: Comment on the PR
|
||||
run: |
|
||||
curl -X POST "https://source.mapcomplete.org/api/v1/repos/${FORGEJO_REPOSITORY}/issues/${PR_NUMBER}/comments" \
|
||||
PR_NUMBER=$(echo ${{ github.event.pull_request.number || github.event.issue.number }})
|
||||
if [[ -n "$PR_NUMBER" ]]
|
||||
then
|
||||
echo "Found a pull request or issue number, will post to $PR_NUMBER ..."
|
||||
MSG=$(echo "Congratulations! This PR been successfully built and has been deployed. It is (temporarily) available on https://builds.mapcomplete.org/${PR_NUMBER}")
|
||||
BODY="{\"body\": \"$MSG\"}"
|
||||
# Token must have following permissions: issue > read and write
|
||||
curl -X POST "https://source.mapcomplete.org/api/v1/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: token $FORGEJO_TOKEN" \
|
||||
-d '{"body": "This PR has been deployed and is (temporarily) available on https://builds.mapcomplete.org/${PR_NUMBER}"}'
|
||||
-d "$BODY"
|
||||
fi
|
||||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue