|
28 | 28 | - name: build documentation second time (for TOC) |
29 | 29 | working-directory: doc |
30 | 30 | run: sphinx-build source build |
| 31 | + |
| 32 | + - name: Get Pullrequest ID |
| 33 | + id: prepare |
| 34 | + run: | |
| 35 | + export PULLREQUEST_ID=$(echo "${{ github.ref }}" | cut -d "/" -f3) |
| 36 | + echo "prid=$PULLREQUEST_ID" >> $GITHUB_OUTPUT |
| 37 | + if [ $(expr length "${{ secrets.USERNAME }}") -gt "1" ]; then echo "uploadtoserver=true" >> $GITHUB_OUTPUT; fi |
| 38 | + - run: | |
| 39 | + echo "baseurl: /${{ steps.prepare.outputs.prid }}" >> _config.yml |
| 40 | +
|
| 41 | + - name: Upload preview |
| 42 | + run: | |
| 43 | + mkdir -p "$HOME/.ssh" |
| 44 | + echo "${{ secrets.KEY }}" > "$HOME/.ssh/key" |
| 45 | + chmod 600 "$HOME/.ssh/key" |
| 46 | + rsync -rILvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/_site/ "${{ secrets.USERNAME }}@chatmail.at:/var/www/html/staging.chatmail.at/docs/relays${{ steps.prepare.outputs.prid }}/" |
| 47 | +
|
| 48 | + - name: "Post links to details" |
| 49 | + id: details |
| 50 | + if: steps.prepare.outputs.uploadtoserver |
| 51 | + run: | |
| 52 | + # URLs for API connection and uploads |
| 53 | + export GITHUB_API_URL="https://api.github.com/repos/chatmail/relay/statuses/${{ github.event.after }}" |
| 54 | + export PREVIEW_LINK="https://staging.chatmail.at/docs/relays${{ steps.prepare.outputs.prid }}/" |
| 55 | + # Post AppImage download link to check details |
| 56 | + export STATUS_DATA="{\"state\": \"success\", \ |
| 57 | + \"description\": \"Preview the page here:\", \ |
| 58 | + \"context\": \"Page Preview\", \ |
| 59 | + \"target_url\": \"${PREVIEW_LINK}\"}" |
| 60 | + curl -X POST --header "Accept: application/vnd.github+json" --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/json" --data "$STATUS_DATA" |
| 61 | +
|
| 62 | + #check if comment already exists, if not post it |
| 63 | + export GITHUB_API_URL="https://api.github.com/repos/chatmail/relay/issues/${{ steps.prepare.outputs.prid }}/comments" |
| 64 | + export RESPONSE=$(curl -L --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28") |
| 65 | + echo $RESPONSE > response |
| 66 | + grep -v '"Check out the page preview at https://staging.chatmail.at/docs/relays' response && echo "comment=true" >> $GITHUB_OUTPUT || true |
| 67 | + - name: "Post link to comments" |
| 68 | + if: steps.details.outputs.comment |
| 69 | + uses: actions/github-script@v7 |
| 70 | + with: |
| 71 | + script: | |
| 72 | + github.rest.issues.createComment({ |
| 73 | + issue_number: context.issue.number, |
| 74 | + owner: context.repo.owner, |
| 75 | + repo: context.repo.repo, |
| 76 | + body: "Check out the page preview at https://staging.chatmail.at/docs/relays${{ steps.prepare.outputs.prid }}/" |
| 77 | + }) |
0 commit comments