Skip to content

Commit 7d41880

Browse files
authored
仅在监听模式下启用 ruby 缓存
1 parent 6689107 commit 7d41880

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

.github/workflows/pr-preview.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
JEKYLL_ENV: production
1313
jobs:
1414
preview-remove:
15-
if: >-
15+
if:
1616
${{
1717
!github.event.repository.fork && (
1818
( github.event_name == 'pull_request_target' && (
@@ -119,7 +119,7 @@ jobs:
119119
name: "preview/watch"
120120
});
121121
preview-create-init:
122-
if: >-
122+
if:
123123
${{
124124
!github.event.repository.fork && (
125125
( github.event_name == 'pull_request_target' && (
@@ -189,6 +189,15 @@ jobs:
189189
preview-create-build:
190190
needs: preview-create-init
191191
runs-on: ubuntu-latest
192+
env:
193+
PREVIEW_WATCH:
194+
${{
195+
contains(github.event.pull_request.labels.*.name, 'preview/watch') ||
196+
contains(github.event.issue.labels.*.name, 'preview/watch') || (
197+
github.event_name == 'issue_comment' &&
198+
github.event.comment.body == '/preview watch'
199+
)
200+
}}
192201
outputs:
193202
artifact-id: ${{ steps.upload-site.outputs.artifact-id }}
194203
steps:
@@ -207,15 +216,8 @@ jobs:
207216
uses: ruby/setup-ruby@v1
208217
with:
209218
ruby-version: "3.4"
210-
bundler-cache: >-
211-
${{
212-
contains(github.event.pull_request.labels.*.name, 'preview/watch') ||
213-
contains(github.event.issue.labels.*.name, 'preview/watch') || (
214-
github.event_name == 'issue_comment' &&
215-
github.event.comment.body == '/preview watch'
216-
)
217-
}}
218-
cache-version: pr${{ env.GITHUB_PR_NUMBER }}
219+
bundler-cache: ${{ env.PREVIEW_WATCH }}
220+
cache-version: PR-${{ env.GITHUB_PR_NUMBER }}
219221
- name: Jekyll Build
220222
run: |
221223
echo "url: https://${{ needs.preview-create-init.outputs.domain }}" > _action.yml
@@ -224,6 +226,7 @@ jobs:
224226
echo "destination: /home/runner/site" >> _action.yml
225227
echo "preview:" >> _action.yml
226228
echo " pr-number: ${{ env.GITHUB_PR_NUMBER }}" >> _action.yml
229+
${{ env.PREVIEW_WATCH }} || bundle install --jobs 4
227230
bundle exec jekyll build --config _config.yml,_action.yml
228231
- id: upload-site
229232
name: Upload Site

0 commit comments

Comments
 (0)