Repository navigation
55 lines (50 loc) · 2 KB
/
Copy pathpreview.yml
File metadata and controls
55 lines (50 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Deploy Preview (manual)
# Deploys the selected branch to Cloudflare Pages (https://<branch>.<project>.pages.dev).
# The preview deployments are protected with Cloudflare Access (login required).
on:
workflow_dispatch:
permissions:
contents: read
env:
CLOUDFLARE_PROJECT: contextmapper-preview
jobs:
preview:
name: Build & Deploy Preview
# master is deployed to contextmapper.org by the "Build & Deploy Website" workflow
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest
environment:
name: preview
url: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
steps:
- uses: actions/checkout@v7
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Build with Jekyll
run: bundle exec jekyll build
env:
JEKYLL_ENV: production
- name: Create Cloudflare Pages project (if it does not exist yet)
run: |
if ! npx --yes wrangler@4 pages project list --json | grep -q "\"$CLOUDFLARE_PROJECT\""; then
npx --yes wrangler@4 pages project create "$CLOUDFLARE_PROJECT" --production-branch=master
fi
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy to Cloudflare Pages
id: deploy
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy _site --project-name=${{ env.CLOUDFLARE_PROJECT }} --branch=${{ github.ref_name }} --commit-hash=${{ github.sha }}
- name: Summary
run: |
echo "### Preview deployed :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Branch: ${{ steps.deploy.outputs.pages-deployment-alias-url }}" >> $GITHUB_STEP_SUMMARY
echo "- This deployment: ${{ steps.deploy.outputs.deployment-url }}" >> $GITHUB_STEP_SUMMARY