diff --git a/.github/workflows/deploy-main.yml b/.github/workflows/deploy-main.yml new file mode 100644 index 000000000..49eb602f5 --- /dev/null +++ b/.github/workflows/deploy-main.yml @@ -0,0 +1,72 @@ +# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) +# +# SPDX-License-Identifier: AGPL-3.0-only + +name: deploy + +on: + push: + branches: [ main ] + +jobs: + deploy: + runs-on: ubuntu-latest + name: Deploys to netlify + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - 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 + uses: actions/cache@v2 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-16-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn + + - name: Set up NodeJS + uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Install dependencies + run: yarn install --immutable + + - name: Build netlify variant + run: yarn build:netlify + + - name: Remove Next.js cache to avoid it being deployed + run: rm -r .next/cache + + - name: Mark GitHub deployment as started + uses: bobheadxi/deployments@v0.6.2 + id: github-deployment + with: + step: start + token: ${{ secrets.GITHUB_TOKEN }} + env: "Latest main" + no_override: false + ref: ${{ github.ref }} + + - name: Run netlify CLI deployment + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + run: bash netlify/deploy-main.sh "${{ github.event.head_commit.id }}" "${{ github.event.head_commit.message }}" + id: netlify-result + + - name: Mark GitHub deployment as finished + if: always() + uses: bobheadxi/deployments@v0.6.2 + with: + step: finish + token: ${{ secrets.GITHUB_TOKEN }} + env_url: ${{ steps.netlify-result.outputs.url }} + logs: ${{ steps.netlify-result.outputs.logs }} + status: ${{ job.status }} + deployment_id: ${{ steps.github-deployment.outputs.deployment_id }} + no_override: false diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy-pr.yml similarity index 94% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy-pr.yml index 7c864d485..2af0321bd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy-pr.yml @@ -56,7 +56,7 @@ jobs: - name: Run netlify CLI deployment env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - run: bash netlify/deploy.sh "${{ github.event.number }}" "${{ github.event.pull_request.title }}" + run: bash netlify/deploy-pr.sh "${{ github.event.number }}" "${{ github.event.pull_request.title }}" id: netlify-result - name: Mark GitHub deployment as finished diff --git a/netlify/deploy-main.sh b/netlify/deploy-main.sh new file mode 100644 index 000000000..1cbc3b697 --- /dev/null +++ b/netlify/deploy-main.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) +# +# SPDX-License-Identifier: AGPL-3.0-only + +json=$(yarn netlify deploy --build --prod --json --message "${1:0:8}: $2") + +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}" diff --git a/netlify/deploy.sh b/netlify/deploy-pr.sh similarity index 100% rename from netlify/deploy.sh rename to netlify/deploy-pr.sh