Pull Request Deploy #69
This file contains 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: Pull Request Deploy | |
# Based on the surge deploy script at https://github.com/ant-design/ant-design-pro | |
on: | |
workflow_run: | |
workflows: | |
- "Pull Request Build" | |
types: | |
- completed | |
concurrency: | |
group: pr-build-${{ github.ref }} | |
cancel-in-progress: false | |
jobs: | |
preview: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Download Artifact | |
uses: dawidd6/action-download-artifact@v2 | |
with: | |
workflow: ${{ github.event.workflow_run.workflow_id }} | |
name: site | |
path: ./docs/ | |
- name: Get PR Number | |
id: pr | |
run: echo "::set-output name=id::$(< ./docs/pr-number.txt)" | |
- name: Create Redirect | |
run: | | |
mkdir site | |
echo "<html><body><div>Redirecting... <a href=\"/docs\">Click Here</a></div><script>window.location = \"/docs\";</script></body></html>" > ./site/index.html | |
- name: Setup NPM | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 8 | |
- name: Install Surge | |
run: npm install -g surge | |
- name: Deploy Surge | |
run: | | |
mv docs site/docs | |
surge ./site/ https://chunky-dev-docs-pr-${{ steps.pr.outputs.id }}.surge.sh --token ${{ secrets.SURGE_TOKEN }} | |
- name: Update Comment - Success | |
uses: actions-cool/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
🎉 PR Preview has been sucessfully built and deployed to https://chunky-dev-docs-pr-${{ steps.pr.outputs.id }}.surge.sh | |
<a href="https://chunky-dev-docs-pr-${{ steps.pr.outputs.id }}.surge.sh"> | |
<img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png"> | |
</a> | |
<!-- Sticky Pull Request Comment --> | |
body-include: "<!-- Sticky Pull Request Comment -->" | |
number: ${{ steps.pr.outputs.id }} | |
- name: Update Comment - Fail | |
if: ${{ failure() }} | |
uses: actions-cool/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body: | | |
😭 PR Preview deployment failed. | |
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png"> | |
<!-- Sticky Pull Request Comment --> | |
body-include: "<!-- Sticky Pull Request Comment -->" | |
number: ${{ steps.pr.outputs.id }} |