Skip to content

Commit

Permalink
Deploy to Cloudflare Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicwortel committed Feb 15, 2024
1 parent 2651974 commit 95ab2ea
Showing 1 changed file with 21 additions and 53 deletions.
74 changes: 21 additions & 53 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,68 +25,36 @@ 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'
needs: [test, build]
needs: [test]
runs-on: ubuntu-latest
environment:
name: production
url: https://www.indexfondsenvergelijken.nl
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

0 comments on commit 95ab2ea

Please sign in to comment.