Skip to content

Commit aeecd32

Browse files
committed
Merge branch 'documentation' into main
2 parents 5ff7e45 + e056dcc commit aeecd32

2 files changed

Lines changed: 42 additions & 17 deletions

File tree

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ To use this action, simply include it as a step in your workflow file. No inputs
99
````yaml
1010
name: My PublicCode Workflow
1111

12+
permissions:
13+
contents: write
14+
1215
on:
1316
push:
1417
branches:
@@ -24,30 +27,38 @@ jobs:
2427

2528
In the above example a `publiccode` file is updated every time code on the `main` branche is touched
2629

27-
> **Warning**
28-
> If you do not supply the action with an access token or an SSH key, you must access your repositories settings and provide `Read and Write Permissions` to the provided `GITHUB_TOKEN`, otherwise you'll potentially run into permission issues. Alternatively you can set the following in your workflow file to grant the action the permissions it needs.
30+
> **Info**
31+
> 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.
32+
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
2939

30-
```yml
31-
permissions:
32-
contents: write
33-
```
3440

3541
## Inputs
3642

37-
| Input Name | Description | Default Value |
38-
|--------------|--------------------------------------------------------------|-----------------------|
39-
| `name` | Git URL of the remote repository to check (Optional) | {{ github.event.repository.name }}" |
40-
| `description` | Git URL of the remote repository to check (Optional) | Empty String |
41-
| `remoterepo` | Git URL of the remote repository to check (Optional) | Empty String |
42-
| `publiccode` | `publiccode.yml` path (Optional), e.g. `data/publiccode.yml` | `publiccode.yml` |
43-
| `gitname` | Git name configuration for bump commit (Optional) | `Open Catalogi bot` |
44-
| `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` |
4553

4654
example ussage of the inputs
4755

4856
````yaml
4957
name: My PublicCode Workflow
5058

59+
permissions:
60+
contents: write
61+
5162
on:
5263
push:
5364
branches:
@@ -98,6 +109,9 @@ Need a quick way to present your project online but don't have the time te creat
98109
````yaml
99110
name: My PublicCode Workflow
100111

112+
permissions:
113+
contents: write
114+
101115
on:
102116
push:
103117
branches:
@@ -110,7 +124,7 @@ jobs:
110124
- name: Update publiccode.yaml
111125
uses: OpenCatalogi/publiccode-action@1.2.1
112126
- name: Deploy Product Github Page
113-
uses: OpenCatalogi/productpage-action@1
127+
uses: OpenCatalogi/productpage-action@1.0.0
114128
````
115129

116130
[Read more](https://github.com/marketplace/actions/create-an-product-page) about the product page action

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)