Add netlify deployments for PRs

Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2022-01-25 16:10:34 +01:00
parent b30cc5b390
commit 523701b3d2
8 changed files with 6932 additions and 109 deletions

72
.github/workflows/deploy.yml vendored Normal file
View file

@ -0,0 +1,72 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: deploy
on:
pull_request:
jobs:
deploy:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
name: Deploys to netlify
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Cache yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-16-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn
- name: Set up NodeJS
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install dependencies
run: yarn install --immutable
- name: Build netlify variant
run: yarn build:netlify
- name: Remove Next.js cache to avoid it being deployed
run: rm -r .next/cache
- name: Mark GitHub deployment as started
uses: bobheadxi/deployments@v0.6.2
id: github-deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: Preview
no_override: false
ref: ${{ github.head_ref }}
- name: Run netlify CLI deployment
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: bash netlify/deploy.sh "${{ github.event.number }}" "${{ github.head_ref }}"
id: netlify-result
- name: Mark GitHub deployment as finished
if: always()
uses: bobheadxi/deployments@v0.6.2
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
env_url: ${{ steps.netlify-result.outputs.url }}
logs: ${{ steps.netlify-result.outputs.logs }}
status: ${{ job.status }}
deployment_id: ${{ steps.github-deployment.outputs.deployment_id }}
no_override: false

4
.gitignore vendored
View file

@ -48,6 +48,10 @@ yarn-error.log*
# vercel # vercel
.vercel .vercel
# netlify
.netlify
!.netlify/state.json
# typescript # typescript
*.tsbuildinfo *.tsbuildinfo

3
.netlify/state.json Normal file
View file

@ -0,0 +1,3 @@
{
"siteId": "329450c0-b852-424e-8b75-7441cefb5bea"
}

View file

@ -47,6 +47,14 @@ Files: .idea/**
Copyright: 2021 The HedgeDoc developers (see AUTHORS file) Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0 License: CC0-1.0
Files: netlify.toml
Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0
Files: .netlify/*
Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0
Files: .github/ISSUE_TEMPLATE/*.md Files: .github/ISSUE_TEMPLATE/*.md
Copyright: 2021 The HedgeDoc developers (see AUTHORS file) Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC-BY-SA-4.0 License: CC-BY-SA-4.0

6
netlify.toml Normal file
View file

@ -0,0 +1,6 @@
[build]
publish = ".next"
command = "echo 'Assuming already built and cleaned Next.js app at ./.next/'"
[[plugins]]
package = "@netlify/plugin-nextjs"

15
netlify/deploy.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
deployid="$1-$2"
json=$(yarn netlify deploy --build --context deploy-preview --alias "${deployid}" --json)
url=$(echo "${json}" | jq -r .deploy_url)
logs=$(echo "${json}" | jq -r .logs)
echo "::set-output name=url::${url}"
echo "::set-output name=logs::${logs}"

View file

@ -144,6 +144,7 @@
"eslint-plugin-promise": "6.0.0", "eslint-plugin-promise": "6.0.0",
"eslint-plugin-testing-library": "5.0.4", "eslint-plugin-testing-library": "5.0.4",
"jest": "27.4.7", "jest": "27.4.7",
"netlify-cli": "8.13.2",
"prettier": "2.5.1", "prettier": "2.5.1",
"react-test-renderer": "17.0.2", "react-test-renderer": "17.0.2",
"redux-devtools-extension": "2.13.9", "redux-devtools-extension": "2.13.9",

6932
yarn.lock

File diff suppressed because it is too large Load diff