2022-01-25 15:10:34 +00:00
|
|
|
# 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
|
2022-03-05 15:27:37 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
- 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
|
2022-04-02 09:07:13 +00:00
|
|
|
uses: actions/cache@v3
|
2022-01-25 15:10:34 +00:00
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
2022-06-15 18:40:26 +00:00
|
|
|
key: ${{ runner.os }}-18-yarn-${{ hashFiles('**/yarn.lock') }}
|
2022-01-25 15:10:34 +00:00
|
|
|
restore-keys: |
|
2022-06-15 18:40:26 +00:00
|
|
|
${{ runner.os }}-yarn-18
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
- name: Set up NodeJS
|
2022-02-26 00:36:32 +00:00
|
|
|
uses: actions/setup-node@v3
|
2022-01-25 15:10:34 +00:00
|
|
|
with:
|
2022-06-15 18:40:26 +00:00
|
|
|
node-version: 18
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-07-30 22:39:49 +00:00
|
|
|
- name: Patch files
|
2022-09-18 19:24:42 +00:00
|
|
|
run: bash netlify/patch-files.sh "https://${{ github.event.number }}--hedgedoc-ui-test.netlify.app/"
|
2022-07-30 22:39:49 +00:00
|
|
|
|
2022-01-25 15:10:34 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: yarn install --immutable
|
|
|
|
|
2022-09-18 18:12:51 +00:00
|
|
|
- name: Build app
|
2022-09-16 09:03:29 +00:00
|
|
|
run: yarn build:mock
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
- name: Remove Next.js cache to avoid it being deployed
|
|
|
|
run: rm -r .next/cache
|
|
|
|
|
|
|
|
- name: Mark GitHub deployment as started
|
2022-06-25 06:50:01 +00:00
|
|
|
uses: bobheadxi/deployments@v1.3.0
|
2022-01-25 15:10:34 +00:00
|
|
|
id: github-deployment
|
|
|
|
with:
|
|
|
|
step: start
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2022-01-27 16:55:01 +00:00
|
|
|
env: "PR #${{ github.event.number }}"
|
2022-02-27 17:26:59 +00:00
|
|
|
override: true
|
2022-01-25 15:10:34 +00:00
|
|
|
ref: ${{ github.head_ref }}
|
|
|
|
|
|
|
|
- name: Run netlify CLI deployment
|
|
|
|
env:
|
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
2022-02-06 13:23:15 +00:00
|
|
|
run: bash netlify/deploy-pr.sh "${{ github.event.number }}" "${{ github.event.pull_request.title }}"
|
2022-01-25 15:10:34 +00:00
|
|
|
id: netlify-result
|
|
|
|
|
|
|
|
- name: Mark GitHub deployment as finished
|
|
|
|
if: always()
|
2022-06-25 06:50:01 +00:00
|
|
|
uses: bobheadxi/deployments@v1.3.0
|
2022-01-25 15:10:34 +00:00
|
|
|
with:
|
|
|
|
step: finish
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
env_url: ${{ steps.netlify-result.outputs.url }}
|
2022-02-27 18:08:35 +00:00
|
|
|
env: ${{ steps.github-deployment.outputs.env }}
|
2022-01-25 15:10:34 +00:00
|
|
|
logs: ${{ steps.netlify-result.outputs.logs }}
|
|
|
|
status: ${{ job.status }}
|
|
|
|
deployment_id: ${{ steps.github-deployment.outputs.deployment_id }}
|
2022-02-27 17:26:59 +00:00
|
|
|
override: true
|