fix(ci): restrict workflow_run deployments to trusted main pushes

This commit is contained in:
xixu-me committed 2026-03-14 01:02:18 +08:00
1 parent 7d3b6673f7
commit 191b3c3635
4 files changed
+16 -5

No files matched your search

+12 -1
View File
@@ -29,7 +29,18 @@ jobs:
packages: write packages: write
id-token: write id-token: write
attestations: write attestations: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }} if: >-
${{
github.event_name == 'workflow_dispatch' ||
startsWith(github.ref, 'refs/tags/v') ||
(
github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'main' &&
github.event.workflow_run.head_repository.full_name == github.repository
)
}}
steps: steps:
- name: Checkout repository - name: Checkout repository
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
permissions: permissions:
contents: read contents: read
deployments: write deployments: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.head_repository.full_name == github.repository) }}
steps: steps:
- name: Checkout pages branch - name: Checkout pages branch
+2 -2
View File
@@ -19,7 +19,7 @@ jobs:
timeout-minutes: 15 timeout-minutes: 15
permissions: permissions:
contents: write contents: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.head_repository.full_name == github.repository) }}
steps: steps:
- name: Checkout main branch - name: Checkout main branch
@@ -91,7 +91,7 @@ jobs:
timeout-minutes: 15 timeout-minutes: 15
permissions: permissions:
contents: write contents: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.head_repository.full_name == github.repository) }}
steps: steps:
- name: Checkout main branch - name: Checkout main branch
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
permissions: permissions:
contents: read contents: read
deployments: write deployments: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.head_repository.full_name == github.repository) }}
steps: steps:
- name: Checkout main branch - name: Checkout main branch
uses: actions/checkout@v6 uses: actions/checkout@v6