-
Notifications
You must be signed in to change notification settings - Fork 6
ci: mirror apps/site to PyModel/pythinker-site #93
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Mirrors apps/site to PyModel/pythinker-site so Dokploy can build the CDN site | ||
| # from a repository that contains nothing else. One-way and force-pushed: this | ||
| # repo is the only source of truth, and any commit made in the mirror is lost on | ||
| # the next push here. | ||
| # | ||
| # Deploy keys are disabled org-wide on PyModel, so the push uses a | ||
| # pythinker-release-bot installation token scoped to pythinker-site only — the | ||
| # same shape release.yml uses for the Homebrew tap. | ||
| name: Mirror site | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'apps/site/**' | ||
| - '.github/workflows/site-mirror.yml' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: site-mirror | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| mirror: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| # git subtree split walks the full history of apps/site. | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Mint release-bot token | ||
| id: release-bot | ||
| uses: actions/create-github-app-token@v2 | ||
| with: | ||
| app-id: ${{ vars.RELEASE_BOT_APP_ID }} | ||
| private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} | ||
| owner: PyModel | ||
| repositories: pythinker-site | ||
|
Comment on lines
+36
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 5 'uses: actions/create-github-app-token|repositories:|permission-contents:' \
.github/workflows/site-mirror.yml .github/workflows/release.ymlRepository: PyModel/pythinker-code Length of output: 3233 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
for name in (".github/workflows/site-mirror.yml", ".github/workflows/release.yml"):
lines = Path(name).read_text().splitlines()
print(f"== {name} ==")
for i, line in enumerate(lines, 1):
if 11 <= i <= 56 or 328 <= i <= 344:
if "uses:" in line or "permission-" in line or "repositories:" in line or "git " in line or "GH_TOKEN" in line:
print(f"{i}: {line}")
PYRepository: PyModel/pythinker-code Length of output: 1136 Restrict the App token to repository contents write access. Add 🧰 Tools🪛 zizmor (1.29.0)[error] 36-36: dangerous use of GitHub App tokens (github-app): app token inherits blanket installation permissions (github-app) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| - name: Push apps/site subtree | ||
| env: | ||
| GH_TOKEN: ${{ steps.release-bot.outputs.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| # subtree split rewrites commits, so it needs an identity. | ||
| git config user.name 'pythinker-release-bot[bot]' | ||
| git config user.email 'pythinker-release-bot[bot]@users.noreply.github.com' | ||
| # subtree split writes a \r-terminated progress counter to stdout, so | ||
| # the sha must be isolated or the refspec colon gets overwritten. | ||
| split="$(git subtree split --prefix=apps/site HEAD | tr -d '\r' | tail -c 41)" | ||
| git push --force \ | ||
| "https://x-access-token:${GH_TOKEN}@github.com/PyModel/pythinker-site.git" \ | ||
| "${split}:refs/heads/main" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: PyModel/pythinker-code
Length of output: 160
🏁 Script executed:
Repository: PyModel/pythinker-code
Length of output: 4935
🏁 Script executed:
Repository: PyModel/pythinker-code
Length of output: 211
Pin both actions to full commit SHAs.
.github/workflows/site-mirror.ymluses mutablev4andv2tags for workflow actions. Replace both references with full commit SHAs to prevent action code from changing without a repository change.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 29-32: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[error] 36-36: dangerous use of GitHub App tokens (github-app): app token inherits blanket installation permissions
(github-app)
🤖 Prompt for AI Agents
Sources: Path instructions, Learnings