From bcc7c9cd20294415740f8aaf41fdcb39a0bc4035 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 6 Aug 2021 23:54:19 +0100 Subject: [PATCH] Use a GitHub action to build the Netlify preview build So we don't need netflify to sit there building the develop branch for no reason. Also it will comment with the URL rather than having to dig it out of the checks. Upload part not tested yet. --- .github/workflows/layered-build.yaml | 19 +++++++++++++++++ .github/workflows/netflify.yaml | 32 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/layered-build.yaml create mode 100644 .github/workflows/netflify.yaml diff --git a/.github/workflows/layered-build.yaml b/.github/workflows/layered-build.yaml new file mode 100644 index 0000000000..1fdf7b7123 --- /dev/null +++ b/.github/workflows/layered-build.yaml @@ -0,0 +1,19 @@ +name: Layered Preview Build +on: + pull_request: + branches: [develop] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build + run: scripts/ci/layered.sh && cd element-web && cp element.io/develop/config.json config.json && CI_PACKAGE=true yarn build + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: Preview Build + path: element-web/webapp + # We'll only use this in a triggered job, then we're done with it + retention-days: 1 + diff --git a/.github/workflows/netflify.yaml b/.github/workflows/netflify.yaml new file mode 100644 index 0000000000..96e4faa930 --- /dev/null +++ b/.github/workflows/netflify.yaml @@ -0,0 +1,32 @@ +name: Upload Preview Build to Netlify +on: + workflow_run: + workflows: ["Layered Preview Build"] + types: + - completed +jobs: + build: + runs-on: ubuntu-latest + if: > + ${{ github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Download Artifact + uses: actions/download-artifact@v2 + with: + name: "Preview Build" + - name: Deploy to Netlify + uses: nwtgck/actions-netlify@v1.2 + with: + publish-dir: . + github-token: ${{ secrets.GITHUB_TOKEN }} + alias: deploy-preview-${{ github.event.number }} + deploy-message: "Deploy from GitHub Actions" + enable-pull-request-comment: true + enable-commit-comment: false + overwrites-pull-request-comment: true + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 1 +