From 8f0e680d4fe9d07a8872fea2becd86c48ce8b88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Tu=C8=99inean?= Date: Tue, 2 Jul 2024 18:43:28 +0300 Subject: [PATCH] separate building from deployment --- .github/workflows/deploy.yml | 42 ++++++++++++++++++++++++++++++++++++ .github/workflows/nextjs.yml | 38 +++++++------------------------- 2 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d5c6f5f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,42 @@ +# Sample workflow for building and deploying a Next.js site to GitHub Pages +# +# To get started with Next.js see: https://nextjs.org/docs/getting-started +# +name: Deploy Next.js site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/nextjs.yml@main + with: + should-upload-artifact: true + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml index 7cfaf4e..bd75f68 100644 --- a/.github/workflows/nextjs.yml +++ b/.github/workflows/nextjs.yml @@ -1,27 +1,16 @@ -# Sample workflow for building and deploying a Next.js site to GitHub Pages -# -# To get started with Next.js see: https://nextjs.org/docs/getting-started -# -name: Deploy Next.js site to Pages +name: Build Next.js site on: - # Runs on pushes targeting the default branch - push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab + pull_request: + workflow_call: + inputs: + should-upload-artifact: + required: false + type: boolean workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true jobs: # Build job @@ -82,17 +71,6 @@ jobs: run: ${{ steps.detect-package-manager.outputs.runner }} next export - name: Upload artifact uses: actions/upload-pages-artifact@v1 + if: ${{ github.event_name == 'workflow_call' && inputs.should-upload-artifact }} with: path: ./out - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1