From 69be81496c6d156b1729f83a859735f8a6c06df8 Mon Sep 17 00:00:00 2001 From: PiX <69745008+pixincreate@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:15:05 +0530 Subject: [PATCH] Add Prod CI --- .github/workflows/CI.yml | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..3d81725 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,64 @@ +name: Build and Deploy Hugo Website + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + permissions: + contents: read + deployments: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: 'latest' + extended: true + + - name: Install Dart Sass + run: sudo snap install dart-sass + + - name: Setup Pages + id: pages + uses: actions/configure-pages@v3 + + - name: Install Node.js dependencies + run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true" + + - name: Build with Hugo + env: + # For maximum backward compatibility with Hugo modules + HUGO_ENVIRONMENT: production + HUGO_ENV: production + run: | + hugo \ + --gc \ + --minify \ + --environment "${HUGO_ENVIRONMENT}" \ + --baseURL "${{ steps.pages.outputs.base_url }}/" + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: ./public + + - name: Deploy + uses: cloudflare/pages-action@1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: "pixincreate_dev" + directory: ./public + gitHubToken: ${{ secrets.GITHUB_TOKEN }}