Skip to content

Commit e056dcc

Browse files
committed
feature: Protected branches
1 parent 774cbe5 commit e056dcc

2 files changed

Lines changed: 31 additions & 10 deletions

File tree

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,26 @@ In the above example a `publiccode` file is updated every time code on the `main
3030
> **Info**
3131
> Alternatively to setting the write permission for the workflow, you can also supply the action with an access token or an SSH key; see inputs for more details.
3232

33+
## Working with protected branches
34+
It is common (and good) practise to protect the main branche of a repository from direct file editing and only allowing this trough pull requests. This will however couse the action (and workflow containing it) to fail becouse the workflow won't have the rights to actually write or create the resulting publiccode or opencatalogi files to the repository.
35+
36+
The sollution here is two run the action two time's
37+
1- Once on the protected branche with the setting `save` set on false to prevent actual file creation or allteration
38+
2- Once on a branche where files may actually be added without a pull request (normally dev or development) setting `federlize` set on false to prevent unnececcery upates to the network
39+
40+
3341
## Inputs
3442

35-
| Input Name | Description | Default Value |
36-
|--------------|--------------------------------------------------------------|-----------------------|
37-
| `name` | Git URL of the remote repository to check (Optional) | {{ github.event.repository.name }}" |
38-
| `description` | Git URL of the remote repository to check (Optional) | Empty String |
39-
| `remoterepo` | Git URL of the remote repository to check (Optional) | Empty String |
40-
| `publiccode` | `publiccode.yml` path (Optional), e.g. `data/publiccode.yml` | `publiccode.yml` |
41-
| `gitname` | Git name configuration for bump commit (Optional) | `Open Catalogi bot` |
42-
| `gitmail` | Git mail configuration for bump commit (Optional) | `bot@opencatalogi.nl` |
43+
| Input Name | Description | Default Value |
44+
|--------------|--------------------------------------------------------------|------------------------------------------|
45+
| `name` | Git URL of the remote repository to check (Optional) | {{ github.event.repository.name }} <br/> |
46+
| `description` | Git URL of the remote repository to check (Optional) | Empty String |
47+
| `remoterepo` | Git URL of the remote repository to check (Optional) | Empty String |
48+
| `publiccode` | `publiccode.yml` path (Optional), e.g. `data/publiccode.yml` | `publiccode.yml` |
49+
| `federlize` | Wheter to send an update event to the federilized open catalogi network | true |
50+
| `save` | Wheter to actually save the file to github | true |
51+
| `gitname` | Git name configuration for bump commit (Optional) | `Open Catalogi bot` |
52+
| `gitmail` | Git mail configuration for bump commit (Optional) | `bot@opencatalogi.nl` |
4353

4454
example ussage of the inputs
4555

action.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ inputs:
2222
required: false
2323
type: boolean
2424
default: false
25+
federlize:
26+
description: 'Wheter to send an update event to the federilized open catalogi network'
27+
required: false
28+
type: boolean
29+
default: true
30+
save:
31+
description: 'Wheter to actually save the file to github'
32+
required: false
33+
type: boolean
34+
default: true
2535
# git configuration
2636
git-name:
2737
description: 'Git name configuration for the commit'
@@ -263,7 +273,7 @@ runs:
263273
264274
# Commit changes if it is a normal repository
265275
- name: Commit changes
266-
if: (!contains(github.repository, '.github'))
276+
if: (!contains(github.repository, '.github') && inputs.save)
267277
shell: bash
268278
run: |
269279
git config --local user.email "${{ inputs.git-mail }}"
@@ -274,7 +284,7 @@ runs:
274284
git push
275285
# Commit changes if it is an organisation repository
276286
- name: Commit changes
277-
if: (contains(github.repository, '.github'))
287+
if: (contains(github.repository, '.github') && inputs.save)
278288
shell: bash
279289
run: |
280290
git config --local user.email "${{ inputs.git-mail }}"
@@ -285,6 +295,7 @@ runs:
285295
git push
286296
# Post Repository URL to OpenCatalogi API
287297
- name: Post Repository URL to OpenCatalogi API
298+
if: (inputs.federlize)
288299
shell: bash
289300
run: |
290301
curl -X POST "https://api.opencatalogi.nl/api/github_events" \

0 commit comments

Comments
 (0)