-
-
Notifications
You must be signed in to change notification settings - Fork 34
78 lines (67 loc) · 3.21 KB
/
jekyll.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Deploy Preview
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
env:
GEM_HOME: ~/.gems
steps:
- name: Get Pullrequest ID
id: prepare
run: |
PULLREQUEST_ID=$(echo "${{ github.ref }}" | cut -d "/" -f3)
echo "prid=$PULLREQUEST_ID" >> $GITHUB_OUTPUT
if test $(expr length "${{ secrets.USERNAME }}") -gt "1"; then
echo "uploadtoserver=true" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v3
- name: Install Bundler
run: sudo gem install bundler
- name: Cache bundle
uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Jekyll
run: bundle install
- name: Build the site with Jekyll
run: |
bundle exec jekyll build --future --baseurl "/${{ steps.prepare.outputs.prid }}"
mkdir ${{ steps.prepare.outputs.prid }}
- name: Upload preview
if: steps.prepare.outputs.uploadtoserver
run: |
mkdir -p "$HOME/.ssh"
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
chmod 600 "$HOME/.ssh/key"
rsync -avzh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/_site/ "${{ secrets.USERNAME }}@mailadm.testrun.org:providerOverview/${{ steps.prepare.outputs.prid }}/"
- name: Post links to details
if: steps.prepare.outputs.uploadtoserver
id: details
run: |
# Post preview link to details.
GITHUB_API_URL="https://api.github.com/repos/deltachat/provider-db/statuses/${{ github.event.after }}"
PREVIEW_LINK="https://mailadm.testrun.org/provider/${{ steps.prepare.outputs.prid }}/"
STATUS_DATA="{\"state\": \"success\", \
\"description\": \"Preview the page here:\", \
\"context\": \"Page Preview\", \
\"target_url\": \"${PREVIEW_LINK}\"}"
curl -X POST --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/json" --data "$STATUS_DATA"
# Check if the comment already exists.
GITHUB_API_URL="https://api.github.com/repos/deltachat/provider-db/issues/${{ steps.prepare.outputs.prid }}/comments"
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")
echo $RESPONSE > result
grep -v '"Check out the page preview at https://mailadm.testrun.org/' result && echo "comment=true" >> $GITHUB_OUTPUT || true
- name: Post link to comments
if: steps.details.outputs.comment
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Check out the page preview at https://mailadm.testrun.org/provider/${{ steps.prepare.outputs.prid }}/"
})