Skip to content

Commit caabb30

Browse files
authoredNov 13, 2024
feat: Adding PR Build and Deploy actions for all PRs (flybywiresim#1056)
1 parent def30d0 commit caabb30

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
 

‎.github/workflows/pr-build.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# build-preview.yml
2+
name: PR Build Preview for Cloudflare
3+
4+
on:
5+
pull_request:
6+
types: [opened, synchronize]
7+
8+
jobs:
9+
build-preview:
10+
runs-on: ubuntu-latest
11+
name: Build Preview Site and Upload Build Artifact
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Setup Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.11'
19+
- name: Install requirements
20+
run: pip install -r requirements.txt
21+
- name: Build PR
22+
run: mkdocs build
23+
24+
# Uploads the build directory as a workflow artifact
25+
- name: Upload build artifact
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: preview-build
29+
path: site

‎.github/workflows/pr-deploy.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# deploy-preview.yml
2+
name: PR Upload Preview to Cloudflare
3+
on:
4+
workflow_run:
5+
workflows: ['PR Build Preview for Cloudflare']
6+
types:
7+
- completed
8+
9+
permissions:
10+
actions: read
11+
deployments: write
12+
contents: read
13+
pull-requests: write
14+
15+
jobs:
16+
deploy-preview:
17+
runs-on: ubuntu-latest
18+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
19+
name: Deploy Preview to Cloudflare Pages
20+
steps:
21+
# Downloads the build directory from the previous workflow
22+
- name: Download build artifact
23+
uses: actions/download-artifact@v4
24+
id: preview-build-artifact
25+
with:
26+
name: preview-build
27+
path: build
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
run-id: ${{ github.event.workflow_run.id }}
30+
31+
- name: Deploy to Cloudflare Pages
32+
uses: AdrianGonz97/refined-cf-pages-action@v1
33+
with:
34+
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }}
35+
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT_ID }}
36+
githubToken: ${{ secrets.GITHUB_TOKEN }}
37+
projectName: ${{ secrets.CLOUDFLARE_DOCS_PROJECT }}
38+
deploymentName: Preview
39+
directory: ${{ steps.preview-build-artifact.outputs.download-path }}

0 commit comments

Comments
 (0)
Please sign in to comment.