Skip to content

Commit 3b68df2

Browse files
ci(workflows): add permissions and general cleanup
1 parent 6754643 commit 3b68df2

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
name: Jekyll CI
3+
permissions:
4+
contents: read
35

46
on:
57
pull_request:
@@ -20,16 +22,18 @@ concurrency:
2022
jobs:
2123
call-jekyll-build:
2224
uses: ./.github/workflows/jekyll-build.yml
23-
with:
24-
target_branch: gh-pages
25-
clean_gh_pages: true
2625
secrets:
2726
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
2827
GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
2928
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
29+
with:
30+
target_branch: gh-pages
31+
clean_gh_pages: true
3032

3133
release:
3234
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
35+
permissions:
36+
contents: write # needed for setup-release-action
3337
runs-on: ubuntu-latest
3438
steps:
3539
- name: Setup Release

.github/workflows/jekyll-build.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
name: Build Jekyll
3+
permissions:
4+
contents: read
35

46
on:
57
workflow_call:
@@ -83,14 +85,14 @@ jobs:
8385
path: theme
8486

8587
- name: Download input artifact
86-
if: ${{ inputs.site_artifact != '' }}
88+
if: inputs.site_artifact != ''
8789
uses: actions/download-artifact@v4
8890
with:
8991
name: ${{ inputs.site_artifact }}
9092
path: project
9193

9294
- name: Extract archive
93-
if: ${{ inputs.site_artifact != '' && inputs.extract_archive != '' }}
95+
if: inputs.site_artifact != '' && inputs.extract_archive != ''
9496
working-directory: project
9597
run: |
9698
case "${{ inputs.extract_archive }}" in
@@ -111,7 +113,7 @@ jobs:
111113
rm -f "${{ inputs.extract_archive }}"
112114
113115
- name: Setup project
114-
if: ${{ github.repository == 'LizardByte/LizardByte.github.io' }}
116+
if: github.repository == 'LizardByte/LizardByte.github.io'
115117
run: |
116118
mkdir -p ./project
117119
cp -RT ./theme/ ./project/
@@ -172,8 +174,7 @@ jobs:
172174
ruby-version: '3.3'
173175

174176
- name: Install dependencies
175-
run: |
176-
bundle install
177+
run: bundle install
177178

178179
- name: Setup Pages
179180
id: configure-pages
@@ -208,8 +209,7 @@ jobs:
208209
209210
- name: Prepare Artifacts # uploading artifacts may fail if not zipped due to very large quantity of files
210211
shell: bash
211-
run: |
212-
7z a _site.zip ./_site/*
212+
run: 7z a _site.zip ./_site/*
213213

214214
- name: Upload artifact
215215
uses: actions/upload-artifact@v4
@@ -224,8 +224,8 @@ jobs:
224224
name: Deploy to Pages
225225
if: >-
226226
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
227-
(github.event_name == 'schedule') ||
228-
(github.event_name == 'workflow_dispatch')
227+
github.event_name == 'schedule' ||
228+
github.event_name == 'workflow_dispatch'
229229
runs-on: ubuntu-latest
230230
needs: build
231231
steps:
@@ -237,11 +237,10 @@ jobs:
237237
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
238238
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
239239

240+
# empty contents of gh-pages
240241
- name: Clean
241-
if: ${{ inputs.clean_gh_pages }}
242-
run: |
243-
# empty contents of gh-pages
244-
rm -f -r ./gh-pages/*
242+
if: inputs.clean_gh_pages
243+
run: rm -f -r ./gh-pages/*
245244

246245
- name: Download artifact
247246
uses: actions/download-artifact@v4

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ This repo contains a reusable workflow to allow for building gh-pages subproject
2525
```yml
2626
---
2727
name: Jekyll CI
28+
permissions:
29+
contents: read
2830

2931
on:
3032
pull_request:
@@ -61,14 +63,14 @@ jobs:
6163
call-jekyll-build:
6264
needs: prep
6365
uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master
64-
with:
65-
site_artifact: 'prep' # any name except 'site' is allowed
66-
target_branch: 'gh-pages'
67-
clean_gh_pages: true
6866
secrets:
6967
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
7068
GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
7169
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
70+
with:
71+
site_artifact: 'prep' # any name except 'site' is allowed
72+
target_branch: 'gh-pages'
73+
clean_gh_pages: true
7274
```
7375
7476
For additional options see [jekyll-build.yml](.github/workflows/jekyll-build.yml)

0 commit comments

Comments
 (0)