diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml new file mode 100644 index 00000000..201f8e3c --- /dev/null +++ b/.github/workflows/preview-build.yml @@ -0,0 +1,41 @@ +name: Preview Build + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build-preview: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - uses: c-hive/gha-yarn-cache@v2 + + - name: build + run: | + yarn + NODE_OPTIONS='--max-old-space-size=4096' yarn build + + - run: | + zip -r docs.zip docs + + - name: upload dist artifact + uses: actions/upload-artifact@v2 + with: + name: docs + path: docs.zip + retention-days: 5 + + - name: Save PR number + if: ${{ always() }} + run: echo ${{ github.event.number }} > ./pr-id.txt + + - name: Upload PR number + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: pr + path: ./pr-id.txt diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml new file mode 100644 index 00000000..aa60b00a --- /dev/null +++ b/.github/workflows/preview-deploy.yml @@ -0,0 +1,85 @@ +name: Preview Deploy + +on: + workflow_run: + workflows: ["Preview Build"] + types: + - completed + +jobs: + success: + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + steps: + - name: download pr artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + name: pr + + - name: save PR id + id: pr + run: echo "::set-output name=id::$( + + body-include: '' + number: ${{ steps.pr.outputs.id }} + - run: | + rm -rf docs/ + - name: The job failed + if: ${{ failure() }} + uses: actions-cool/maintain-one-comment@v1.1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + 😭 Deploy PR Preview failed. + + + body-include: '' + number: ${{ steps.pr.outputs.id }} + + failed: + runs-on: ubuntu-latest + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' + steps: + - name: download pr artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + name: pr + + - name: save PR id + id: pr + run: echo "::set-output name=id::$( + + body-include: '' + number: ${{ steps.pr.outputs.id }} diff --git a/.github/workflows/preview-start.yml b/.github/workflows/preview-start.yml new file mode 100644 index 00000000..57afdaa8 --- /dev/null +++ b/.github/workflows/preview-start.yml @@ -0,0 +1,17 @@ +name: Preview Start + +on: pull_request_target + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - name: create + uses: actions-cool/maintain-one-comment@v1.1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + body: | + ⚡️ Deploying PR Preview... + + + body-include: ''