hedgedoc/.github/workflows/frontend-netlify-deploy-main.yml
Tilman Vatteroth 31e4ab5e37
fix(frontend): move and rename workflows
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
2022-11-20 21:29:17 +01:00

68 lines
2 KiB
YAML

# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: deploy
on:
push:
branches: [ main ]
env:
NETLIFY_VERSION: 12.0.11
NODE_VERSION: 18
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploys to netlify
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Cache yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
- name: Set up NodeJS
uses: actions/setup-node@v3
with:
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
- 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
- name: Install dependencies
run: yarn install --immutable
- name: Build app
run: yarn build:mock
- name: Remove Next.js cache to avoid it being deployed
run: rm -r .next/cache
- name: Install netlify CLI
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
- name: Run netlify CLI deployment
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: "netlify deploy --build --prod --message \"${{ github.event.head_commit.id }}: ${{ github.event.head_commit.message }}\""