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: add concurrency settings and improve permissions in workflow files (#6534)

白熱db7f777c4e10
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index a88b2e080c..be460d55d9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -8,6 +8,10 @@ on:
branches:
- dev
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
permissions:
contents: read
@@ -22,10 +26,10 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v4
+ uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
- ref: ${{ github.head_ref }}
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup Node.js
uses: ./.github/actions/setup-node
diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml
index 8eb3fd5696..6d986bcbf6 100644
--- a/.github/workflows/ci-test.yml
+++ b/.github/workflows/ci-test.yml
@@ -8,6 +8,10 @@ on:
branches:
- dev
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
permissions:
contents: read
pull-requests: write
diff --git a/.github/workflows/dev-performance-log.yml b/.github/workflows/dev-performance-log.yml
index 97c2aa678a..e7d0fa27b9 100644
--- a/.github/workflows/dev-performance-log.yml
+++ b/.github/workflows/dev-performance-log.yml
@@ -5,6 +5,13 @@ on:
branches:
- dev
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
jobs:
e2e-test:
runs-on: ubuntu-latest
@@ -27,6 +34,12 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
+ - name: Cache Playwright browsers
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/ms-playwright
+ key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index 645a2e7b64..9f40a5eec8 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -5,6 +5,15 @@ on:
branches:
- dev
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+ pull-requests: write
+ actions: write
+
jobs:
e2e-test:
runs-on: ubuntu-latest
@@ -19,6 +28,12 @@ jobs:
- name: Setup Node.js
uses: ./.github/actions/setup-node
+ - name: Cache Playwright browsers
+ uses: actions/cache@v4
+ with:
+ path: ~/.cache/ms-playwright
+ key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
+
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps chromium
diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml
index 8bd02db5b1..eb5419e48c 100644
--- a/.github/workflows/preview-deploy.yml
+++ b/.github/workflows/preview-deploy.yml
@@ -7,13 +7,18 @@ on:
types:
- completed
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch || github.ref }}
+ cancel-in-progress: true
+
permissions:
contents: read
pull-requests: write
+ actions: read
jobs:
setup:
- if: ${{ github.event.workflow_run.conclusion == 'success' }}
+ if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_repository.full_name == github.repository }}
runs-on: ubuntu-latest
outputs:
diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml
index f00ff653f6..0341e0f735 100644
--- a/.github/workflows/setup.yml
+++ b/.github/workflows/setup.yml
@@ -7,8 +7,13 @@ on:
branches: [dev]
permissions:
+ actions: write
pull-requests: read
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
set-pr-info:
name: set PR info
@@ -16,8 +21,8 @@ jobs:
steps:
- name: Save PR info
run: |
- echo ${{ github.event.pull_request.number }} > ./pr-id.txt
- echo ${{ github.head_ref }} >> ./pr-ref.txt
+ 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
- name: Upload PR number