Skip to content

Commit da12696

Browse files
committed
Add repo owner check and customisable input
1 parent a59d664 commit da12696

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,34 @@ on:
2323
required: false
2424
default: 'ubuntu-latest'
2525
type: string
26+
repo-owner:
27+
description: 'Repository owner/organization allowed to run this workflow'
28+
required: false
29+
default: 'electricbookworks'
30+
type: string
2631

2732
jobs:
33+
owner-check:
34+
runs-on: ${{ inputs.runner }}
35+
outputs:
36+
is_allowed_owner: ${{ steps.check_owner.outputs.is_allowed_owner }}
37+
steps:
38+
- name: Check repository owner
39+
id: check_owner
40+
run: |
41+
REPO_OWNER="${{ github.repository_owner }}"
42+
ALLOWED_OWNER="${{ inputs.repo-owner }}"
43+
if [ "$REPO_OWNER" != "$ALLOWED_OWNER" ]; then
44+
echo "⚠️ Repository owner '$REPO_OWNER' is not '$ALLOWED_OWNER'. Skipping workflow execution."
45+
echo "is_allowed_owner=false" >> $GITHUB_OUTPUT
46+
else
47+
echo "✅ Repository owner '$REPO_OWNER' is authorized. Proceeding with workflow."
48+
echo "is_allowed_owner=true" >> $GITHUB_OUTPUT
49+
fi
50+
2851
pre-check:
52+
needs: owner-check
53+
if: needs.owner-check.outputs.is_allowed_owner == 'true'
2954
runs-on: ${{ inputs.runner }}
3055
outputs:
3156
skip_book_server: ${{ steps.check_config.outputs.skip_book_server }}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
2424
Replace `{release-version}` with the latest release (e.g. `v2.0.2`), unless you want to use an older version.
2525

26-
You can also add optional inputs to customise the Ruby and Node versions, as well as the config file location:
26+
You can also provide the following optional inputs, under the `with` property:
2727

2828
```yaml
2929
name: Deploy to Electric Book Server and S3
@@ -40,6 +40,7 @@ jobs:
4040
config-file: '.github/workflows/deploy.config.json' # optional - defaults to '.github/workflows/deploy.config.json'
4141
node-version: '22' # optional - defaults to 22
4242
runner: 'Linux-4core-16gb-ram-150gb-sso' # optional - defaults to 'ubuntu-latest'
43+
repo-owner: 'electricbookworks' # optional - defaults to 'electricbookworks' - if not a match, workflow will be skipped
4344
```
4445

4546
### 2. Create your deployment configuration

0 commit comments

Comments
 (0)