From b6b4cc6628bdee0f50f5c016f08d53e4e9874fb3 Mon Sep 17 00:00:00 2001 From: Nic Wortel Date: Fri, 16 Feb 2024 00:04:24 +0100 Subject: [PATCH] Deploy to Cloudflare Pages --- .github/workflows/build.yaml | 72 ++++++++++-------------------------- 1 file changed, 20 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 07b3200..17c5f2f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,46 +25,6 @@ jobs: - name: Run tests run: yarn test - build: - name: Build - if: github.event_name == 'push' - needs: test - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.prep.outputs.tag }} - steps: - - name: Checkout source code - uses: actions/checkout@v2 - - name: Prepare - id: prep - run: echo "::set-output name=tag::ghcr.io/nicwortel/indexfondsenvergelijken.nl:${GITHUB_SHA::8}" - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Login to GitHub Packages Docker Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Pull Docker images - run: docker-compose pull - - name: Restore Docker layer cache - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: Build and push the Docker image - uses: docker/build-push-action@v2 - with: - push: true - tags: | - ghcr.io/nicwortel/indexfondsenvergelijken.nl:latest - ${{ steps.prep.outputs.tag }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - deploy: name: Deploy if: github.event_name == 'push' @@ -76,17 +36,25 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v2 - - name: Set the Kubernetes context - uses: azure/k8s-set-context@v1 + + - name: Restore NPM cache + uses: actions/cache@v2 with: - method: service-account - k8s-url: ${{ secrets.KUBERNETES_CLUSTER_URL }} - k8s-secret: ${{ secrets.KUBERNETES_SECRET }} - - name: Deploy to the Kubernetes cluster - uses: azure/k8s-deploy@v1 + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Install NPM packages + run: yarn install + + - name: Build the website + run: make dist + + - name: Deploy to Cloudflare Pages + uses: cloudflare/pages-action@v1 with: - namespace: indexfondsenvergelijken - manifests: | - kubernetes/deployment.yaml - images: | - ${{ needs.build.outputs.tag }} + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: 8a52e15d16e945b8f72ffec4c9c31396 + projectName: indexfondsenvergelijken + directory: dist