mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 21:33:59 -05:00
fix(ci): run workflows in target repository context
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
410e5b2222
commit
dfba39266a
11 changed files with 109 additions and 108 deletions
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
|
@ -6,9 +6,9 @@ name: test, build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -20,9 +20,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get yarn cache directory path
|
- name: Get yarn cache directory path
|
||||||
id: yarn-cache-dir-path
|
id: yarn-cache-dir-path
|
||||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache yarn cache
|
- name: Cache yarn cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
|
@ -31,13 +33,17 @@ jobs:
|
||||||
key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-${{ matrix.node }}
|
${{ runner.os }}-yarn-${{ matrix.node }}
|
||||||
|
|
||||||
- name: Set up NodeJS
|
- name: Set up NodeJS
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
run: yarn install --immutable
|
||||||
|
|
||||||
- name: Test Project
|
- name: Test Project
|
||||||
run: yarn test:ci
|
run: yarn test:ci
|
||||||
|
|
||||||
- name: Build project
|
- name: Build project
|
||||||
run: yarn build:mock
|
run: yarn build:mock
|
||||||
|
|
28
.github/workflows/deploy-main.yml
vendored
28
.github/workflows/deploy-main.yml
vendored
|
@ -8,6 +8,10 @@ on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
NETLIFY_VERSION: 12.0.11
|
||||||
|
NODE_VERSION: 18
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -25,17 +29,26 @@ jobs:
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
key: ${{ runner.os }}-18-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-18
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Set up NodeJS
|
- name: Set up NodeJS
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Patch files
|
- name: Patch intro.md to include netlify banner.
|
||||||
run: bash netlify/patch-files.sh "https://hedgedoc.dev/"
|
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
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
run: yarn install --immutable
|
||||||
|
@ -46,7 +59,10 @@ jobs:
|
||||||
- name: Remove Next.js cache to avoid it being deployed
|
- name: Remove Next.js cache to avoid it being deployed
|
||||||
run: rm -r .next/cache
|
run: rm -r .next/cache
|
||||||
|
|
||||||
|
- name: Install netlify CLI
|
||||||
|
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
|
||||||
|
|
||||||
- name: Run netlify CLI deployment
|
- name: Run netlify CLI deployment
|
||||||
env:
|
env:
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
run: bash netlify/deploy-main.sh "${{ github.event.head_commit.id }}" "${{ github.event.head_commit.message }}"
|
run: "netlify deploy --build --prod --message \"${{ github.event.head_commit.id }}: ${{ github.event.head_commit.message }}\""
|
||||||
|
|
51
.github/workflows/deploy-pr.yml
vendored
51
.github/workflows/deploy-pr.yml
vendored
|
@ -5,13 +5,30 @@
|
||||||
name: deploy
|
name: deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request_target:
|
||||||
|
branches: [ main ]
|
||||||
|
types:
|
||||||
|
- labeled
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
deployments: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
NETLIFY_VERSION: 12.0.11
|
||||||
|
NODE_VERSION: 18
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
if: github.event.pull_request.draft == false
|
if: github.event.pull_request.draft == false || contains( github.event.pull_request.labels.*.name, 'FORCE DEPLOY').
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Deploys to netlify
|
name: Deploys to netlify
|
||||||
|
env:
|
||||||
|
DEPLOY_URL: "https://${{ github.event.number }}--hedgedoc-ui-test.netlify.app/"
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -25,17 +42,26 @@ jobs:
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
key: ${{ runner.os }}-18-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-18
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Set up NodeJS
|
- name: Set up NodeJS
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Patch files
|
- name: Patch intro.md to include netlify banner.
|
||||||
run: bash netlify/patch-files.sh "https://${{ github.event.number }}--hedgedoc-ui-test.netlify.app/"
|
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=\"${{ env.DEPLOY_URL }}\"" >> .env.production
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
run: yarn install --immutable
|
||||||
|
@ -56,11 +82,13 @@ jobs:
|
||||||
override: true
|
override: true
|
||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
- name: Run netlify CLI deployment
|
- name: Install netlify CLI
|
||||||
|
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
|
||||||
|
|
||||||
|
- name: Run netlify CLI
|
||||||
env:
|
env:
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
run: bash netlify/deploy-pr.sh "${{ github.event.number }}" "${{ github.event.pull_request.title }}"
|
run: "netlify deploy --build --context deploy-preview --alias \"${{ github.event.number }}\" --json --message \"PR #${{ github.event.number }}\""
|
||||||
id: netlify-result
|
|
||||||
|
|
||||||
- name: Mark GitHub deployment as finished
|
- name: Mark GitHub deployment as finished
|
||||||
if: always()
|
if: always()
|
||||||
|
@ -68,9 +96,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
step: finish
|
step: finish
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
env_url: ${{ steps.netlify-result.outputs.url }}
|
env_url: ${{ env.DEPLOY_URL }}
|
||||||
env: ${{ steps.github-deployment.outputs.env }}
|
env: ${{ steps.github-deployment.outputs.env }}
|
||||||
logs: ${{ steps.netlify-result.outputs.logs }}
|
|
||||||
status: ${{ job.status }}
|
status: ${{ job.status }}
|
||||||
deployment_id: ${{ steps.github-deployment.outputs.deployment_id }}
|
deployment_id: ${{ steps.github-deployment.outputs.deployment_id }}
|
||||||
override: true
|
override: true
|
||||||
|
|
24
.github/workflows/e2e.yml
vendored
24
.github/workflows/e2e.yml
vendored
|
@ -7,9 +7,15 @@ name: e2e
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
pull_request:
|
pull_request_target:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_VERSION: 18
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-frontend:
|
build-frontend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -36,15 +42,15 @@ jobs:
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true'
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
key: ${{ runner.os }}-18-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-18
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Set up NodeJS
|
- name: Set up NodeJS
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true'
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true'
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
|
@ -93,9 +99,15 @@ jobs:
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
key: ${{ runner.os }}-16-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-16
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Set up NodeJS
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
run: yarn install --immutable
|
||||||
|
|
13
.github/workflows/lint.yml
vendored
13
.github/workflows/lint.yml
vendored
|
@ -6,9 +6,12 @@ name: lint
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_VERSION: 18
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
|
@ -27,14 +30,14 @@ jobs:
|
||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
key: ${{ runner.os }}-18-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-yarn-18
|
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Set up NodeJS
|
- name: Set up NodeJS
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 18
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable
|
run: yarn install --immutable
|
||||||
|
|
4
.github/workflows/reuse.yml
vendored
4
.github/workflows/reuse.yml
vendored
|
@ -6,9 +6,9 @@ name: REUSE Compliance Check
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
reuse:
|
reuse:
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
#
|
|
||||||
|
|
||||||
json=$($(dirname "$0")/netlify-cli.sh deploy --build --prod --json --message "${1:0:8}: $2")
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error while executing netlify! Will try again without json..."
|
|
||||||
$(dirname "$0")/netlify-cli.sh deploy --build --prod --message "${1:0:8}: $2"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${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}"
|
|
|
@ -1,23 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
#
|
|
||||||
|
|
||||||
json=$($(dirname "$0")/netlify-cli.sh deploy --build --context deploy-preview --alias "$1" --json --message "[#$1] $2")
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Error while executing netlify! Will try again without json..."
|
|
||||||
$(dirname "$0")/netlify-cli.sh deploy --build --context deploy-preview --alias "$1" --message "[#$1] $2"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${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}"
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
#
|
|
||||||
|
|
||||||
NETLIFY_VERSION=12.0.11
|
|
||||||
exec npx --yes netlify-cli@${NETLIFY_VERSION} $@
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
#
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo 'Patch intro.md to include netlify banner.'
|
|
||||||
cp netlify/intro.md public/public/intro.md
|
|
||||||
echo 'Patch motd.md to include privacy policy.'
|
|
||||||
cp netlify/motd.md public/public/motd.md
|
|
||||||
echo 'Patch version.json to include git hash'
|
|
||||||
jq ".version = \"0.0.0+${GITHUB_SHA:0:8}\"" src/version.json > src/_version.json
|
|
||||||
mv src/_version.json src/version.json
|
|
||||||
echo "Patch base URL"
|
|
||||||
echo HD_EDITOR_BASE_URL="${1}" >> .env.production
|
|
|
@ -93,13 +93,24 @@
|
||||||
"regexManagers": [
|
"regexManagers": [
|
||||||
{
|
{
|
||||||
"fileMatch": [
|
"fileMatch": [
|
||||||
"netlify-cli.sh$"
|
".github/workflows/deploy-main.yml$",
|
||||||
|
".github/workflows/deploy-pr.yml$"
|
||||||
],
|
],
|
||||||
"matchStrings": [
|
"matchStrings": [
|
||||||
"NETLIFY_VERSION=(?<currentValue>.*?)\\n"
|
"NETLIFY_VERSION=(?<currentValue>.*?)\\n"
|
||||||
],
|
],
|
||||||
"datasourceTemplate" : "npm",
|
"datasourceTemplate" : "npm",
|
||||||
"depNameTemplate" : "netlify-cli"
|
"depNameTemplate" : "netlify-cli"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fileMatch": [
|
||||||
|
".github/workflows/deploy-main.yml$",
|
||||||
|
".github/workflows/deploy-pr.yml$"
|
||||||
|
],
|
||||||
|
"matchStrings": [
|
||||||
|
"NODE_VERSION=(?<currentValue>.*?)\\n"
|
||||||
|
],
|
||||||
|
"datasourceTemplate" : "node"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue