diff --git a/.github/workflows/website-pages.yml b/.github/workflows/website-pages.yml new file mode 100644 index 000000000..bc1e444dc --- /dev/null +++ b/.github/workflows/website-pages.yml @@ -0,0 +1,52 @@ +name: Website Pages + +on: + push: + branches: [main] + paths: + - "website/**" + - ".github/workflows/website-pages.yml" + pull_request: + branches: [main] + paths: + - "website/**" + - ".github/workflows/website-pages.yml" + workflow_dispatch: + +permissions: + contents: read + deployments: write + +env: + CLOUDFLARE_PROJECT_NAME: skillshare + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "22" + cache: npm + cache-dependency-path: website/package-lock.json + + - name: Install dependencies + working-directory: website + run: npm ci + + - name: Build website + working-directory: website + run: npm run build + + - name: Deploy to Cloudflare Pages + if: github.event_name != 'pull_request' + uses: cloudflare/wrangler-action@v3 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: pages deploy website/build --project-name=${{ env.CLOUDFLARE_PROJECT_NAME }} --branch=${{ github.ref_name }} + gitHubToken: ${{ secrets.GITHUB_TOKEN }}