improve page #77
This file contains hidden or 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: Deploy Preview | |
| on: [pull_request] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v1 | |
| - name: Get Pullrequest ID | |
| id: prepare | |
| run: | | |
| export PULLREQUEST_ID=$(echo "${{ github.ref }}" | cut -d "/" -f3) | |
| echo ::set-output name=prid::$PULLREQUEST_ID | |
| if [ $(expr length "${{ secrets.USERNAME }}") -gt "1" ]; then echo ::set-output name=uploadtoserver::true ;fi | |
| - name: Build the site in the jekyll/builder container | |
| if: steps.prepare.outputs.uploadtoserver | |
| run: | | |
| docker run \ | |
| -v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \ | |
| jekyll/builder:latest /bin/bash -c "chmod 777 /srv/jekyll -R && jekyll build --future --baseurl /${{ steps.prepare.outputs.prid }}/" | |
| mkdir ${{ steps.prepare.outputs.prid }} | |
| - name: Create folder if it doesn't exist | |
| if: steps.prepare.outputs.uploadtoserver | |
| uses: horochx/deploy-via-scp@v1.0.1 | |
| with: | |
| user: ${{ secrets.USERNAME }} | |
| key: ${{ secrets.KEY }} | |
| host: "staging.bots.delta.chat" | |
| port: 22 | |
| local: ${{ steps.prepare.outputs.prid }} | |
| remote: "/var/www/html/bot-staging/${{ steps.prepare.outputs.prid }}" | |
| - name: Upload preview | |
| if: steps.prepare.outputs.uploadtoserver | |
| uses: horochx/deploy-via-scp@v1.0.1 | |
| with: | |
| user: ${{ secrets.USERNAME }} | |
| key: ${{ secrets.KEY }} | |
| host: "staging.bots.delta.chat" | |
| port: 22 | |
| local: "_site/*" | |
| remote: "/var/www/html/bot-staging/${{ steps.prepare.outputs.prid }}/" | |
| - name: "Post links to details" | |
| id: details | |
| if: steps.prepare.outputs.uploadtoserver | |
| run: | | |
| # URLs for API connection and uploads | |
| export GITHUB_API_URL="https://api.github.com/repos/deltachat-bot/bot-pages/statuses/${{ github.event.after }}" | |
| export PREVIEW_LINK="https://staging.bots.delta.chat/${{ steps.prepare.outputs.prid }}/" | |
| # Post AppImage download link to check details | |
| export STATUS_DATA="{\"state\": \"success\", \ | |
| \"description\": \"Preview the page here:\", \ | |
| \"context\": \"Page Preview\", \ | |
| \"target_url\": \"${PREVIEW_LINK}\"}" | |
| export RESPONSE=$(curl -X POST --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/json" --data "$STATUS_DATA" | jq -r .message) | |
| if [ "$RESPONSE" == "Not Found" ]; then echo ::set-output name=comment::true ;fi | |
| - name: "Post link to comments" | |
| if: steps.details.outputs.comment | |
| uses: rytswd/respost@v0.1.0 | |
| with: | |
| body: "Check out the page preview at https://staging.bots.delta.chat/${{ steps.prepare.outputs.prid }}/" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |