2022-01-25 10:10:34 -05:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
name: deploy
|
|
|
|
|
|
|
|
on:
|
2022-02-06 08:23:15 -05:00
|
|
|
push:
|
|
|
|
branches: [ main ]
|
2022-01-25 10:10:34 -05:00
|
|
|
|
2022-10-21 12:57:29 -04:00
|
|
|
env:
|
|
|
|
NETLIFY_VERSION: 12.0.11
|
|
|
|
NODE_VERSION: 18
|
|
|
|
|
2022-01-25 10:10:34 -05:00
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Deploys to netlify
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-03-05 10:27:37 -05:00
|
|
|
uses: actions/checkout@v3
|
2022-01-25 10:10:34 -05:00
|
|
|
|
|
|
|
- name: Get yarn cache directory path
|
|
|
|
id: yarn-cache-dir-path
|
2022-10-19 16:47:03 -04:00
|
|
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
2022-01-25 10:10:34 -05:00
|
|
|
|
|
|
|
- name: Cache yarn cache
|
2022-04-02 05:07:13 -04:00
|
|
|
uses: actions/cache@v3
|
2022-01-25 10:10:34 -05:00
|
|
|
id: yarn-cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
2022-10-21 12:57:29 -04:00
|
|
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
2022-01-25 10:10:34 -05:00
|
|
|
restore-keys: |
|
2022-10-21 12:57:29 -04:00
|
|
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
2022-01-25 10:10:34 -05:00
|
|
|
|
|
|
|
- name: Set up NodeJS
|
2022-02-25 19:36:32 -05:00
|
|
|
uses: actions/setup-node@v3
|
2022-01-25 10:10:34 -05:00
|
|
|
with:
|
2022-10-21 12:57:29 -04:00
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
|
|
|
|
- name: Patch intro.md to include netlify banner.
|
|
|
|
run: cp netlify/intro.md public/public/intro.md
|
|
|
|
|
|
|
|
- name: Patch motd.md to include privacy policy.
|
|
|
|
run: cp netlify/motd.md public/public/motd.md
|
2022-01-25 10:10:34 -05:00
|
|
|
|
2022-10-21 12:57:29 -04:00
|
|
|
- name: Patch version.json to include git hash
|
|
|
|
run: jq ".version = \"0.0.0+${GITHUB_SHA:0:8}\"" src/version.json > src/_version.json && mv src/_version.json src/version.json
|
|
|
|
|
|
|
|
- name: Patch base URL
|
|
|
|
run: echo "HD_EDITOR_BASE_URL=\"https://hedgedoc.dev/\"" >> .env.production
|
2022-07-30 18:39:49 -04:00
|
|
|
|
2022-01-25 10:10:34 -05:00
|
|
|
- name: Install dependencies
|
|
|
|
run: yarn install --immutable
|
|
|
|
|
2022-09-18 14:12:51 -04:00
|
|
|
- name: Build app
|
|
|
|
run: yarn build:mock
|
2022-01-25 10:10:34 -05:00
|
|
|
|
|
|
|
- name: Remove Next.js cache to avoid it being deployed
|
|
|
|
run: rm -r .next/cache
|
|
|
|
|
2022-10-21 12:57:29 -04:00
|
|
|
- name: Install netlify CLI
|
|
|
|
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
|
|
|
|
|
2022-01-25 10:10:34 -05:00
|
|
|
- name: Run netlify CLI deployment
|
|
|
|
env:
|
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
2022-10-21 12:57:29 -04:00
|
|
|
run: "netlify deploy --build --prod --message \"${{ github.event.head_commit.id }}: ${{ github.event.head_commit.message }}\""
|