Skip to content

Commit 61c60c0

Browse files
committed
add upload
1 parent 6598ca8 commit 61c60c0

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/docs.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,50 @@ jobs:
2828
- name: build documentation second time (for TOC)
2929
working-directory: doc
3030
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

Comments
 (0)