From f6677889e055d5f940fce2705e85cc8999a0a9f2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 19:11:45 +0100 Subject: [PATCH 1/8] Hopefully deploy main branch to netlify --- .github/workflows/build.yaml | 26 +++++++++++ .github/workflows/netlify-main.yaml | 70 +++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/netlify-main.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..885be8f --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,26 @@ +name: Build +on: + push: + branches: [main] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Yarn cache + uses: actions/setup-node@v3 + with: + cache: 'yarn' + - name: Install dependencies + run: "yarn install" + - name: Build + run: "yarn run build" + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: build + path: element-call/dist + # We'll only use this in a triggered job, then we're done with it + retention-days: 1 diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml new file mode 100644 index 0000000..b6cf5fa --- /dev/null +++ b/.github/workflows/netlify-main.yaml @@ -0,0 +1,70 @@ +name: Netlify Main +on: + workflow_run: + workflows: ["Build"] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' + steps: + - name: Create Deployment + uses: bobheadxi/deployments@v1 + id: deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: Netlify + ref: ${{ github.event.workflow_run.head_sha }} + + - name: 'Download artifact' + uses: actions/github-script@v3.1.0 + with: + script: | + const artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + const matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "build" + })[0]; + const download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + const fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data)); + + - name: Extract Artifacts + run: unzip -d webapp build.zip && rm build.zip + + - name: Deploy to Netlify + id: netlify + uses: nwtgck/actions-netlify@v1.2 + with: + publish-dir: dist + deploy-message: "Deploy from GitHub Actions" + # These don't work because we're in workflow_run + enable-pull-request-comment: false + enable-commit-comment: false + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + timeout-minutes: 1 + + - name: Update deployment status + uses: bobheadxi/deployments@v1 + if: always() + with: + step: finish + override: false + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + env: ${{ steps.deployment.outputs.env }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + env_url: ${{ steps.netlify.outputs.deploy-url }} From 970568fd17bbb7158932eb205fb6ddd3f5dcf21f Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 19:19:22 +0100 Subject: [PATCH 2/8] yaml indenting --- .github/workflows/netlify-main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml index b6cf5fa..f34ff77 100644 --- a/.github/workflows/netlify-main.yaml +++ b/.github/workflows/netlify-main.yaml @@ -19,7 +19,7 @@ jobs: env: Netlify ref: ${{ github.event.workflow_run.head_sha }} - - name: 'Download artifact' + - name: 'Download artifact' uses: actions/github-script@v3.1.0 with: script: | From d8fe617535d6babb25c94710d47d7a8347ec6072 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 19:20:15 +0100 Subject: [PATCH 3/8] Try this path --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 885be8f..00be1b0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,6 +21,6 @@ jobs: uses: actions/upload-artifact@v2 with: name: build - path: element-call/dist + path: dist # We'll only use this in a triggered job, then we're done with it retention-days: 1 From 455bb0910804e0072c9cb0498443c1b006470566 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 19:35:40 +0100 Subject: [PATCH 4/8] Try bumping token permissions --- .github/workflows/netlify-main.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml index f34ff77..94de829 100644 --- a/.github/workflows/netlify-main.yaml +++ b/.github/workflows/netlify-main.yaml @@ -8,6 +8,8 @@ on: jobs: deploy: runs-on: ubuntu-latest + permissions: + deployments: write if: github.event.workflow_run.conclusion == 'success' steps: - name: Create Deployment From 04c6d990bdfdc2797e2fd79f5ec710279b795c4c Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 19:39:27 +0100 Subject: [PATCH 5/8] Make dir name match --- .github/workflows/netlify-main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml index 94de829..1ec366e 100644 --- a/.github/workflows/netlify-main.yaml +++ b/.github/workflows/netlify-main.yaml @@ -43,7 +43,7 @@ jobs: fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data)); - name: Extract Artifacts - run: unzip -d webapp build.zip && rm build.zip + run: unzip -d dist build.zip && rm build.zip - name: Deploy to Netlify id: netlify From f2232a074003c842cd1dc860af2449bd3bbee4a2 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 19:55:05 +0100 Subject: [PATCH 6/8] Enable production deploys and also remove the manual deployment updating as it looks like the netlify action supports it anyway --- .github/workflows/netlify-main.yaml | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml index 1ec366e..b46e272 100644 --- a/.github/workflows/netlify-main.yaml +++ b/.github/workflows/netlify-main.yaml @@ -12,15 +12,6 @@ jobs: deployments: write if: github.event.workflow_run.conclusion == 'success' steps: - - name: Create Deployment - uses: bobheadxi/deployments@v1 - id: deployment - with: - step: start - token: ${{ secrets.GITHUB_TOKEN }} - env: Netlify - ref: ${{ github.event.workflow_run.head_sha }} - - name: 'Download artifact' uses: actions/github-script@v3.1.0 with: @@ -47,26 +38,17 @@ jobs: - name: Deploy to Netlify id: netlify - uses: nwtgck/actions-netlify@v1.2 + uses: nwtgck/actions-netlify@v1.2.3 with: publish-dir: dist deploy-message: "Deploy from GitHub Actions" + production-branch: main + production-deploy: true # These don't work because we're in workflow_run enable-pull-request-comment: false enable-commit-comment: false + github-deployment-environment: main env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} timeout-minutes: 1 - - - name: Update deployment status - uses: bobheadxi/deployments@v1 - if: always() - with: - step: finish - override: false - token: ${{ secrets.GITHUB_TOKEN }} - status: ${{ job.status }} - env: ${{ steps.deployment.outputs.env }} - deployment_id: ${{ steps.deployment.outputs.deployment_id }} - env_url: ${{ steps.netlify.outputs.deploy-url }} From b2418d53846daf088217a3d60d6f7bc061ea619d Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 20:48:30 +0100 Subject: [PATCH 7/8] Put manual deployment updating back the netlify action's deployment updating doesn't seem to work --- .github/workflows/netlify-main.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/netlify-main.yaml b/.github/workflows/netlify-main.yaml index b46e272..a9ab069 100644 --- a/.github/workflows/netlify-main.yaml +++ b/.github/workflows/netlify-main.yaml @@ -12,6 +12,15 @@ jobs: deployments: write if: github.event.workflow_run.conclusion == 'success' steps: + - name: Create Deployment + uses: bobheadxi/deployments@v1 + id: deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: main-branch-cd + ref: ${{ github.event.workflow_run.head_sha }} + - name: 'Download artifact' uses: actions/github-script@v3.1.0 with: @@ -52,3 +61,15 @@ jobs: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} timeout-minutes: 1 + + - name: Update deployment status + uses: bobheadxi/deployments@v1 + if: always() + with: + step: finish + override: false + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + env: ${{ steps.deployment.outputs.env }} + deployment_id: ${{ steps.deployment.outputs.deployment_id }} + env_url: ${{ steps.netlify.outputs.deploy-url }} From abdfcd879dd9450ec2ece5d69716ee7dc81c8534 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 10 May 2022 21:24:20 +0100 Subject: [PATCH 8/8] Hopefully add sentry to cd builds --- .github/workflows/build.yaml | 5 +++++ src/main.jsx | 1 + 2 files changed, 6 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 00be1b0..7bf9faa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,6 +2,11 @@ name: Build on: push: branches: [main] +env: + VITE_DEFAULT_HOMESERVER: "https://call.ems.host" + VITE_SENTRY_DSN: https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41 + VITE_SENTRY_ENVIRONMENT: main-branch-cd + VITE_RAGESHAKE_SUBMIT_URL: https://element.io/bugreports/submit jobs: build: name: Build diff --git a/src/main.jsx b/src/main.jsx index d620ff9..d9a87d2 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -54,6 +54,7 @@ const history = createBrowserHistory(); Sentry.init({ dsn: import.meta.env.VITE_SENTRY_DSN, + environment: import.meta.env.VITE_SENTRY_ENVIRONMENT ?? "production", integrations: [ new Integrations.BrowserTracing({ routingInstrumentation: Sentry.reactRouterV5Instrumentation(history),