-
Notifications
You must be signed in to change notification settings - Fork 93
security: Ci/fix validate workflow #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
qtipbera
wants to merge
9
commits into
main
Choose a base branch
from
ci/fix-validate-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
881debb
security: split secrets from fork-processing workflow
qtipbera f7a363e
Potential fix for pull request finding
qtipbera c303f3f
fix: upgrade all actions to node24, pin base checkouts, fix pnpm v2
qtipbera c82e23d
fix: remove workflow_run.head_sha ref from post-validate checkout
qtipbera 9503eba
chore: trigger CI
qtipbera fe2cffd
chore: trigger CI
qtipbera 2d85abc
fix: disable setup-node v5 auto-cache
qtipbera 4c1ebe0
Merge remote-tracking branch 'origin/main' into ci/fix-validate-workflow
qtipbera 60e0ccb
fixing broken validate workflow
qtipbera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # This workflow handles the secret-dependent upload step. | ||
| # It runs AFTER the Validate workflow completes and never checks out fork code. | ||
| # Secrets (Cloudflare creds) only exist in this workflow, isolated from | ||
| # any fork-controlled input. | ||
| # | ||
| # The artifact bridge: | ||
| # Validate (pull_request_target, no secrets) | ||
| # └── packages asset files + PR metadata as artifacts | ||
| # Post-Validate (workflow_run, has secrets) | ||
| # └── downloads artifacts, uploads to Cloudflare using base branch scripts | ||
|
|
||
| name: Post-Validate | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["Validate"] | ||
| types: [completed] | ||
|
|
||
| jobs: | ||
| upload-assets: | ||
| runs-on: ubuntu-latest | ||
| if: github.event.workflow_run.conclusion == 'success' | ||
| environment: cloudflare-uploads | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| actions: read | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| package-manager-cache: false | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 | ||
| with: | ||
| version: 9.15.9 | ||
|
|
||
| - name: Get pnpm store directory | ||
| shell: bash | ||
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
|
|
||
| - name: Setup pnpm cache | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: ${{ env.STORE_PATH }} | ||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pnpm-store- | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| # Read PR metadata from artifact saved by Validate workflow. | ||
| # We use artifacts instead of workflow_run.pull_requests[] because | ||
| # that array is empty for fork PRs (known GitHub limitation). | ||
| - name: Download PR info | ||
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | ||
| with: | ||
| name: pr-info | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ github.token }} | ||
|
|
||
| - name: Read PR metadata | ||
| id: pr | ||
| run: | | ||
| echo "number=$(cat pr_number.txt)" >> $GITHUB_OUTPUT | ||
| echo "head_repo=$(cat pr_head_repo.txt)" >> $GITHUB_OUTPUT | ||
| echo "head_sha=$(cat pr_head_sha.txt)" >> $GITHUB_OUTPUT | ||
|
|
||
|
qtipbera marked this conversation as resolved.
|
||
| # Try to download the asset artifact. If no assets changed in the PR, | ||
| # the Validate workflow skipped the package-assets job and this artifact | ||
| # won't exist — that's expected, so continue-on-error. | ||
| - name: Download asset files | ||
| id: download-assets | ||
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | ||
| with: | ||
| name: pr-assets | ||
| path: ./head/src/assets/ | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ github.token }} | ||
| continue-on-error: true | ||
|
|
||
| - name: Upload changed images to Cloudflare Images | ||
| if: steps.download-assets.outcome == 'success' | ||
| env: | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| CLOUDFLARE_IMAGES_API_TOKEN: ${{ secrets.CLOUDFLARE_IMAGES_API_TOKEN }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
| PR_NUMBER: ${{ steps.pr.outputs.number }} | ||
| run: pnpm upload:assets ./head | ||
|
|
||
| - name: Post summary comment | ||
| if: always() && steps.download-assets.outcome == 'success' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR: ${{ steps.pr.outputs.number }} | ||
| run: | | ||
| if [ -s "$GITHUB_STEP_SUMMARY" ]; then | ||
| gh pr comment "$PR" --body-file "$GITHUB_STEP_SUMMARY" | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.