Skip to content

Fix bug with cancelled seervices #86

Fix bug with cancelled seervices

Fix bug with cancelled seervices #86

name: Build and deploy to Cloudflare Pages
on: push
jobs:
build-jekyll:
runs-on: ubuntu-22.04
container:
image: ruby:3.3.1
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract-branch
- name: Install gems
run: bundle install
- name: Calculate branch alias URL
if: steps.extract-branch.outputs.branch != 'main'
uses: schnerring/cloudflare-pages-branch-alias-action@v1.0.3
id: pages-branch-alias
with:
git-branch: ${{ steps.extract-branch.outputs.branch }}
- name: Set Jekyll URL
if: steps.extract-branch.outputs.branch != 'main'
uses: mikefarah/yq@v4.44.2
with:
cmd: yq -i '.url = "https://${{ steps.pages-branch-alias.outputs.branch-alias }}.beh-uk.pages.dev"' '_config.yml'
- name: Build website (non-production)
if: steps.extract-branch.outputs.branch != 'main'
run: bundle exec jekyll build --drafts --future
- name: Build website (production)
if: steps.extract-branch.outputs.branch == 'main'
run: bundle exec jekyll build
env:
JEKYLL_ENV: production
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: jekyll-website
if-no-files-found: error
path: _site/
validate-d1:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Create tables in local database beh-uk-forms
uses: cloudflare/wrangler-action@v3
with:
command: d1 execute beh-uk-forms --local --file=./sql/beh-uk-forms-schema.sql
deploy-to-cloudflare-pages:
needs: [build-jekyll, validate-d1]
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract-branch
- name: Download built website
uses: actions/download-artifact@v4
with:
name: jekyll-website
path: _site
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy _site --project-name=beh-uk --branch=${{ steps.extract-branch.outputs.branch }} --commit-dirty=true
deploy-d1:
needs: [build-jekyll, validate-d1]
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Deploy tables to remote database beh-uk-forms
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: d1 execute beh-uk-forms --file=./sql/beh-uk-forms-schema.sql