Uplift download-artifact to v4.3.0 #112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and deploy to Cloudflare Pages | |
| on: push | |
| jobs: | |
| build-jekyll: | |
| runs-on: ubuntu-24.04 | |
| container: | |
| image: ruby:3.4.4 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4.2.2 | |
| - 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.3.0 | |
| 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.45.4 | |
| 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.6.2 | |
| with: | |
| name: jekyll-website | |
| if-no-files-found: error | |
| path: _site/ | |
| validate-d1: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4.2.2 | |
| - name: Create tables in local database beh-uk-forms | |
| uses: cloudflare/wrangler-action@v3.14.1 | |
| 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-24.04 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4.2.2 | |
| - 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.3.0 | |
| with: | |
| name: jekyll-website | |
| path: _site | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3.14.1 | |
| 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-24.04 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4.2.2 | |
| - name: Deploy tables to remote database beh-uk-forms | |
| uses: cloudflare/wrangler-action@v3.14.1 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: d1 execute beh-uk-forms --file=./sql/beh-uk-forms-schema.sql |