2022-01-25 15:10:34 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
name: Frontend / Deploy develop branch to Netlify
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
on:
|
2022-02-06 13:23:15 +00:00
|
|
|
push:
|
2022-11-11 09:55:08 +00:00
|
|
|
branches: [ develop ]
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-10-21 16:57:29 +00:00
|
|
|
env:
|
|
|
|
NETLIFY_VERSION: 12.0.11
|
|
|
|
NODE_VERSION: 18
|
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: frontend
|
|
|
|
|
|
|
|
concurrency:
|
2022-12-05 17:40:59 +00:00
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
|
2022-11-11 09:55:08 +00:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-01-25 15:10:34 +00:00
|
|
|
jobs:
|
2022-11-11 09:55:08 +00:00
|
|
|
changes:
|
|
|
|
name: Check for frontend changes
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
outputs:
|
2022-11-21 16:24:36 +00:00
|
|
|
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
|
2022-11-11 09:55:08 +00:00
|
|
|
steps:
|
2022-11-20 21:16:54 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-11-21 16:24:36 +00:00
|
|
|
if: github.event_name != 'push'
|
|
|
|
|
2022-11-11 09:55:08 +00:00
|
|
|
- name: Check for frontend file changes
|
2022-11-21 16:24:36 +00:00
|
|
|
if: github.event_name != 'push'
|
2022-11-11 09:55:08 +00:00
|
|
|
uses: dorny/paths-filter@v2
|
|
|
|
id: changed
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
files:
|
2022-12-04 21:41:39 +00:00
|
|
|
- 'commons/**'
|
2022-11-11 09:55:08 +00:00
|
|
|
- 'frontend/**'
|
|
|
|
- '.github/**'
|
|
|
|
- '.yarn/**'
|
|
|
|
|
2022-01-25 15:10:34 +00:00
|
|
|
deploy:
|
2022-11-11 09:55:08 +00:00
|
|
|
needs: changes
|
2022-01-25 15:10:34 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Deploys to netlify
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-03-05 15:27:37 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-11-29 16:36:57 +00:00
|
|
|
- name: Setup node
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-11-29 16:36:57 +00:00
|
|
|
uses: ./.github/actions/setup-node
|
2022-01-25 15:10:34 +00:00
|
|
|
with:
|
2022-11-29 16:36:57 +00:00
|
|
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
2022-10-21 16:57:29 +00:00
|
|
|
|
|
|
|
- name: Patch intro.md to include netlify banner.
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-10-21 16:57:29 +00:00
|
|
|
run: cp netlify/intro.md public/public/intro.md
|
|
|
|
|
|
|
|
- name: Patch motd.md to include privacy policy.
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-10-21 16:57:29 +00:00
|
|
|
run: cp netlify/motd.md public/public/motd.md
|
2022-01-25 15:10:34 +00:00
|
|
|
|
2022-10-21 16:57:29 +00:00
|
|
|
- name: Patch version.json to include git hash
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-10-21 16:57:29 +00:00
|
|
|
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
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-10-21 16:57:29 +00:00
|
|
|
run: echo "HD_EDITOR_BASE_URL=\"https://hedgedoc.dev/\"" >> .env.production
|
2022-07-30 22:39:49 +00:00
|
|
|
|
2022-09-18 18:12:51 +00:00
|
|
|
- name: Build app
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-09-18 18:12:51 +00:00
|
|
|
run: yarn build:mock
|
2022-01-25 15:10:34 +00:00
|
|
|
|
|
|
|
- name: Remove Next.js cache to avoid it being deployed
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-01-25 15:10:34 +00:00
|
|
|
run: rm -r .next/cache
|
|
|
|
|
2022-10-21 16:57:29 +00:00
|
|
|
- name: Install netlify CLI
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-10-21 16:57:29 +00:00
|
|
|
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
|
|
|
|
|
2022-01-25 15:10:34 +00:00
|
|
|
- name: Run netlify CLI deployment
|
2022-11-11 09:55:08 +00:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-01-25 15:10:34 +00:00
|
|
|
env:
|
|
|
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
2022-10-21 16:57:29 +00:00
|
|
|
run: "netlify deploy --build --prod --message \"${{ github.event.head_commit.id }}: ${{ github.event.head_commit.message }}\""
|