Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

ci: harden GitHub Actions token handling

白熱33799973daa4
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index be460d55d9..a76c246540 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -30,6 +30,7 @@ jobs:
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml
index 6d986bcbf6..64e19c12a5 100644
--- a/.github/workflows/ci-test.yml
+++ b/.github/workflows/ci-test.yml
@@ -23,6 +23,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
@@ -41,6 +43,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
@@ -54,6 +58,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
diff --git a/.github/workflows/dev-performance-log.yml b/.github/workflows/dev-performance-log.yml
index 547692f319..782fe535fe 100644
--- a/.github/workflows/dev-performance-log.yml
+++ b/.github/workflows/dev-performance-log.yml
@@ -23,6 +23,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Set Env
run: |
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 9f40a5eec8..a5a35180ea 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -24,6 +24,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml
index eb5419e48c..0deafb04c0 100644
--- a/.github/workflows/preview-deploy.yml
+++ b/.github/workflows/preview-deploy.yml
@@ -110,6 +110,7 @@ jobs:
with:
repository: ${{ needs.setup.outputs.repo }}
ref: ${{ needs.setup.outputs.ref }}
+ persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@v4
@@ -180,6 +181,7 @@ jobs:
with:
repository: ${{ needs.setup.outputs.repo }}
ref: ${{ needs.setup.outputs.ref }}
+ persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@v4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a0e322bfc4..bf90bc489d 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -13,7 +13,7 @@ concurrency:
cancel-in-progress: true
permissions:
- contents: write
+ contents: read
jobs:
prepare:
@@ -26,7 +26,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
- token: ${{ secrets.GH_TOKEN }}
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
@@ -51,6 +51,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
+ persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@v4
@@ -88,6 +89,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
@@ -119,6 +122,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
+ with:
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml
index 0341e0f735..b506f4f9fb 100644
--- a/.github/workflows/setup.yml
+++ b/.github/workflows/setup.yml
@@ -20,10 +20,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Save PR info
+ env:
+ PR_ID: ${{ github.event.pull_request.number || '' }}
+ PR_REF: ${{ github.head_ref || github.ref_name }}
+ PR_REPO: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
run: |
- echo ${{ github.event.pull_request.number || '' }} > ./pr-id.txt
- echo ${{ github.head_ref || github.ref_name }} >> ./pr-ref.txt
- echo ${{ github.event.pull_request.head.repo.full_name || github.repository }} >> ./pr-repo.txt
+ printf '%s\n' "$PR_ID" > ./pr-id.txt
+ printf '%s\n' "$PR_REF" > ./pr-ref.txt
+ printf '%s\n' "$PR_REPO" > ./pr-repo.txt
- name: Upload PR number
uses: actions/upload-artifact@v4
diff --git a/.github/workflows/sync-pro.yml b/.github/workflows/sync-pro.yml
index 6fec468086..0ac08c6ab1 100644
--- a/.github/workflows/sync-pro.yml
+++ b/.github/workflows/sync-pro.yml
@@ -12,7 +12,7 @@ jobs:
steps:
- name: Dispatch sync event to univer-pro
- uses: peter-evans/repository-dispatch@v2
+ uses: peter-evans/repository-dispatch@v4
with:
repository: dream-num/univer-pro
token: ${{ secrets.GH_TOKEN }}
@@ -22,14 +22,3 @@ jobs:
"ref": "${{ github.ref_name }}",
"sha": "${{ github.sha }}"
}
- - name: Dispatch sync event to univer-labs
- uses: peter-evans/repository-dispatch@v2
- with:
- repository: dream-num/univer-labs
- token: ${{ secrets.GH_TOKEN }}
- event-type: sync-univer
- client-payload: >
- {
- "ref": "${{ github.ref_name }}",
- "sha": "${{ github.sha }}"
- }
diff --git a/.github/workflows/update-snapshots-manually.yml b/.github/workflows/update-snapshots-manually.yml
index 40b6d3ced6..965e5b60cc 100644
--- a/.github/workflows/update-snapshots-manually.yml
+++ b/.github/workflows/update-snapshots-manually.yml
@@ -4,6 +4,9 @@ name: 📸 Manually Update Snapshots
on:
workflow_dispatch:
+permissions:
+ contents: read
+
jobs:
update-snapshots:
runs-on: ubuntu-latest
@@ -14,7 +17,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
- token: ${{ secrets.GH_TOKEN }}
+ persist-credentials: false
- name: Setup Node.js
uses: ./.github/actions/setup-node
@@ -24,11 +27,14 @@ jobs:
- name: Commit Updated Snapshots
shell: bash
+ env:
+ PUSH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
+ git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git status
git add -A
git commit -m "chore(snapshots): update snapshots" || exit 0
- git push
+ git push origin "HEAD:${GITHUB_REF_NAME}"
diff --git a/package.json b/package.json
index 9ced6dd85c..1476a5fa7f 100644
--- a/package.json
+++ b/package.json
@@ -89,15 +89,13 @@
"vitest": "^4.1.1"
},
"pnpm": {
- "onlyBuiltDependencies": [
- "esbuild"
- ]
- },
- "resolutions": {
- "@types/react": "19.2.14",
- "@types/react-dom": "19.2.3",
- "react": "19.2.4",
- "react-dom": "19.2.4"
+ "overrides": {
+ "@types/react": "19.2.14",
+ "@types/react-dom": "19.2.3",
+ "basic-ftp": "5.2.0",
+ "react": "19.2.4",
+ "react-dom": "19.2.4"
+ }
},
"lint-staged": {
"*": "eslint --fix"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e09cf6b263..d0ffd947ce 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -7,6 +7,7 @@ settings:
overrides:
'@types/react': 19.2.14
'@types/react-dom': 19.2.3
+ basic-ftp: 5.2.0
react: 19.2.4
react-dom: 19.2.4
@@ -6258,8 +6259,8 @@ packages:
resolution: {integrity: sha512-ZCQ9GEWl73BVm8bu5Fts8nt7MHdbt5vY9bP6WGnUh+r3l8M7CgfyTlwsgCbMC66BNxPr6Xoce3j66Ms5YUQTNA==}
hasBin: true
- resolution: {integrity: sha512-RkaJzeJKDbaDWTIPiJwubyljaEPwpVWkm9Rt5h9Nd6h7tEXTJ3VB4qxdZBioV7JO5yLUaOKwz7vDOzlncUsegw==}
+ resolution: {integrity: sha512-VoMINM2rqJwJgfdHq6RiUudKt2BV+FY5ZFezP/ypmwayk68+NzzAQy4XXLlqsGD4MCzq3DrmNFD/uUmBJuGoXw==}
engines: {node: '>=10.0.0'}
@@ -14195,7 +14196,7 @@ snapshots:
@@ -15847,7 +15848,7 @@ snapshots:
dependencies:
- basic-ftp: 5.1.0
+ basic-ftp: 5.2.0
data-uri-to-buffer: 6.0.2
debug: 4.4.3
transitivePeerDependencies: