From 9a21812a46a036653599688f9c8c8721576e4a54 Mon Sep 17 00:00:00 2001 From: Alok Gupta Date: Sat, 29 Jun 2024 15:15:08 +0530 Subject: [PATCH] github-actions : Add workflow to deploy to production --- .github/workflows/preview-deployment.yml | 2 +- .github/workflows/production-deployment.yml | 64 +++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/production-deployment.yml diff --git a/.github/workflows/preview-deployment.yml b/.github/workflows/preview-deployment.yml index f95ba451a..64b65b99e 100644 --- a/.github/workflows/preview-deployment.yml +++ b/.github/workflows/preview-deployment.yml @@ -81,5 +81,5 @@ jobs: accountId: ${{ secrets.CF_ACCOUNT_ID }} githubToken: ${{ secrets.GITHUB_TOKEN }} projectName: ${{ vars.CF_PROJECT_NAME }} - directory: .next + directory: out deploymentName: Preview \ No newline at end of file diff --git a/.github/workflows/production-deployment.yml b/.github/workflows/production-deployment.yml new file mode 100644 index 000000000..b659b6231 --- /dev/null +++ b/.github/workflows/production-deployment.yml @@ -0,0 +1,64 @@ +name: Docs Production Deployment +on: + push: + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + name: Publish to Cloudflare Pages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Cache Node dependencies + uses: actions/cache@v4 + id: yarn-cache + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Cache Next Build + uses: actions/cache@v4 + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + ${{ github.workspace }}/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build Site + run: yarn run build + + - name: Deploy to Cloudflare Pages + uses: AdrianGonz97/refined-cf-pages-action@v1 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: ${{ secrets.CF_ACCOUNT_ID }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectName: ${{ vars.CF_PROJECT_NAME }} + directory: out + deploymentName: Production \ No newline at end of file