From 276308ff0dc8cdb3299afc10c94ceac653ea6ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Kazami=20=5B=E4=B9=94=E6=B2=BB=C2=B7=E9=A2=A8?= =?UTF-8?q?=E8=A6=8B=5D?= Date: Sat, 18 Feb 2023 14:07:39 +0000 Subject: [PATCH] chore: add cf pages deploy --- .github/workflows/dev-cloudflare-pages.yml | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/dev-cloudflare-pages.yml diff --git a/.github/workflows/dev-cloudflare-pages.yml b/.github/workflows/dev-cloudflare-pages.yml new file mode 100644 index 0000000..6988d65 --- /dev/null +++ b/.github/workflows/dev-cloudflare-pages.yml @@ -0,0 +1,109 @@ +name: Deploy DEV EOEFANS WEB to Cloudflare pages + +on: + push: + branches: [ "main","ci" ] +# pull_request: +# types: [synchronize, closed] +# branches: [ "main","ci" ] + +# Environment variables available to all jobs and steps in this workflow +env: + APP_LOCATION: "/" # location of your client code + APP_ARTIFACT_LOCATION: "dist" # location of client code build output + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + RPOJECT_NAME: eoefans-landing-dev + +permissions: + contents: read + +jobs: + build_and_deploy_job: + permissions: + contents: read + deployments: write + pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: [ self-hosted, Linux ] + environment: + name: 'Development' + + strategy: + matrix: + node-version: [18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + + - uses: actions/setup-node@v3 + name: Use Node.js ${{ matrix.node-version }} + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm install + + - name: Use npm to build + run: npm run build + +# - uses: pnpm/action-setup@v2 +# name: Install pnpm +# id: pnpm-install +# with: +# version: 7 +# run_install: false + +# - name: Get pnpm store directory +# id: pnpm-cache +# shell: bash +# run: | +# echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT + +# - uses: actions/cache@v3 +# name: Setup pnpm cache +# with: +# path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} +# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} +# restore-keys: | +# ${{ runner.os }}-pnpm-store- + +# - name: Install dependencies +# run: pnpm install + +# - name: Use pnpm to build +# run: pnpm run build + +# - name: post-build test +# run: pnpm test + + - name: Publish + uses: cloudflare/pages-action@1 + with: + apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + projectName: eoefans-web-dev # e.g. 'my-project' + directory: ${{ env.APP_ARTIFACT_LOCATION }} # e.g. 'dist' + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + + close_pull_request_job: + permissions: + contents: none + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: [ self-hosted, Linux ] + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: cloudflare/pages-action@1 + with: + apiToken: ${{ env.CLOUDFLARE_API_TOKEN }} + accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }} + projectName: ${{ env.RPOJECT_NAME }} # e.g. 'my-project' + directory: ${{ env.APP_ARTIFACT_LOCATION }} # e.g. 'dist' + gitHubToken: ${{ secrets.GITHUB_TOKEN }}