Skip to content

Commit 0fc4ffa

Browse files
authored
chore(ci): Update CloudFlare previews to run on adding label (#2901)
## Description This PR adds a label check for the PR Previews on cloudflare. This is required as CloudFlare only allows 500 deployments in a month. By adding this label we can regulate the number of deployments per PR. ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [x] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here>
1 parent b9167d9 commit 0fc4ffa

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

.github/workflows/docs_preview_build_cf.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ name: "CF: Build Docs Preview"
1717

1818
on:
1919
pull_request:
20+
types: [opened, synchronize, reopened, labeled]
2021
paths:
2122
- 'docs/**'
2223
- '.github/workflows/docs*_cf.yaml'
@@ -26,6 +27,7 @@ permissions: read-all
2627

2728
jobs:
2829
build-preview:
30+
if: "contains(github.event.pull_request.labels.*.name, 'docs: deploy-preview')"
2931
runs-on: ubuntu-24.04
3032
env:
3133
PR_NUMBER: ${{ github.event.number }}
@@ -86,4 +88,27 @@ jobs:
8688
echo "The build for PR #${{ env.PR_NUMBER }} succeeded." >> $GITHUB_STEP_SUMMARY
8789
echo "The Cloudflare deployment workflow is now starting." >> $GITHUB_STEP_SUMMARY
8890
echo "---" >> $GITHUB_STEP_SUMMARY
89-
echo "#### [Track Deployment Progress]($DEPLOY_URL)" >> $GITHUB_STEP_SUMMARY
91+
echo "#### [Track Deployment Progress]($DEPLOY_URL)" >> $GITHUB_STEP_SUMMARY
92+
93+
remove-label:
94+
needs: build-preview
95+
if: "always() && contains(github.event.pull_request.labels.*.name, 'docs: deploy-preview')"
96+
runs-on: ubuntu-24.04
97+
permissions:
98+
pull-requests: write
99+
steps:
100+
- name: Remove deploy-preview label
101+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
102+
with:
103+
script: |
104+
try {
105+
await github.rest.issues.removeLabel({
106+
owner: context.repo.owner,
107+
repo: context.repo.repo,
108+
issue_number: context.issue.number,
109+
name: 'docs: deploy-preview'
110+
});
111+
console.log("Label 'docs: deploy-preview' removed successfully.");
112+
} catch (error) {
113+
console.log(`Error removing label: ${error}`);
114+
}

DEVELOPER.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ go test -race -v ./cmd/... ./internal/...
382382
workflows on your PR.
383383
* Maintainers can comment `/gcbrun` to execute the integration tests.
384384
* Maintainers can add the label `tests:run` to execute the unit tests.
385+
* Maintainers can add the label `docs: deploy-preview` to run the PR Preview workflow.
385386
386387
#### Test Resources
387388

0 commit comments

Comments
 (0)