-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adding PR Build and Deploy actions for all PRs (#1056)
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# build-preview.yml | ||
name: PR Build Preview for Cloudflare | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
|
||
jobs: | ||
build-preview: | ||
runs-on: ubuntu-latest | ||
name: Build Preview Site and Upload Build Artifact | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
- name: Install requirements | ||
run: pip install -r requirements.txt | ||
- name: Build PR | ||
run: mkdocs build | ||
|
||
# Uploads the build directory as a workflow artifact | ||
- name: Upload build artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: preview-build | ||
path: site |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# deploy-preview.yml | ||
name: PR Upload Preview to Cloudflare | ||
on: | ||
workflow_run: | ||
workflows: ['PR Build Preview for Cloudflare'] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
actions: read | ||
deployments: write | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
deploy-preview: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
name: Deploy Preview to Cloudflare Pages | ||
steps: | ||
# Downloads the build directory from the previous workflow | ||
- name: Download build artifact | ||
uses: actions/download-artifact@v4 | ||
id: preview-build-artifact | ||
with: | ||
name: preview-build | ||
path: build | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Deploy to Cloudflare Pages | ||
uses: AdrianGonz97/refined-cf-pages-action@v1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_PAGES_ACCOUNT_ID }} | ||
githubToken: ${{ secrets.GITHUB_TOKEN }} | ||
projectName: ${{ secrets.CLOUDFLARE_DOCS_PROJECT }} | ||
deploymentName: Preview | ||
directory: ${{ steps.preview-build-artifact.outputs.download-path }} |