Skip to content

Commit 5e889d5

Browse files
committed
Merge branch 'feature/public-action' into main
2 parents fa9c120 + 4e54306 commit 5e889d5

8 files changed

Lines changed: 345 additions & 66 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: PublicCode and PublicOrganization Check and Update
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- feature/public-action
9+
- feature/mark-debug
10+
11+
jobs:
12+
check-and-update:
13+
runs-on: ubuntu-latest
14+
steps:
15+
# Check out the code
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
# Install Python
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.x'
23+
# Transfer the repossitory data to the container
24+
- name: Transfer the repossitory data to the container
25+
run: |
26+
echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
27+
echo "REPO_DESC=${{ github.event.repository.description }}" >> $GITHUB_ENV
28+
echo "REPO_URL=${{ github.event.repository.html_url }}" >> $GITHUB_ENV
29+
echo "REPO_HOMEPAGE=${{ github.event.repository.homepage }}" >> $GITHUB_ENV
30+
echo "REPO_LICENSE=${{ github.event.repository.license.key }}" >> $GITHUB_ENV
31+
echo "REPO_CREATED_AT=${{ github.event.repository.created_at }}" >> $GITHUB_ENV
32+
33+
echo "ORGANISATION_NAME=${{ github.event.organization.login }}" >> $GITHUB_ENV
34+
echo "ORGANISATION_DESCRIPTION=${{ github.event.organization.description }}" >> $GITHUB_ENV
35+
echo "ORGANISATION_GITID=${{ github.event.organization.id}}" >> $GITHUB_ENV
36+
echo "ORGANISATION_URL=${{ github.event.organization.login }}" >> $GITHUB_ENV
37+
echo "ORGANISATION_AVATAR=${{ github.event.organization.avatar_url }}" >> $GITHUB_ENV
38+
39+
echo "Installing PyYAML..."
40+
pip install PyYAML
41+
# Create changes if it is a normal repository
42+
- name: Create or update the publiccode file
43+
if: (!contains(github.repository, '.github'))
44+
run: python update_publiccode.py
45+
shell: bash
46+
# Create changes if it is an organisation repository
47+
- name: Create or update the publicorganisation file
48+
if: (contains(github.repository, '.github'))
49+
run: python update_publicorganisation.py
50+
shell: bash
51+
# Commit changes if it is a normal repository
52+
- name: Commit changes
53+
if: (!contains(github.repository, '.github'))
54+
run: |
55+
git config --local user.email "action@github.com"
56+
git config --local user.name "GitHub Action"
57+
git add publiccode.yaml
58+
git commit -m "${{ github.workflow }}" || echo "No changes to commit"
59+
git push
60+
# Commit changes if it is an organisation repository
61+
- name: Commit changes
62+
if: (contains(github.repository, '.github'))
63+
run: |
64+
git config --local user.email "action@github.com"
65+
git config --local user.name "GitHub Action"
66+
git add publicorganisation.yaml
67+
git commit -m "${{ github.workflow }}" || echo "No changes to commit"
68+
git push
69+
# Post Repository URL to OpenCatalogi API
70+
- name: Post Repository URL to OpenCatalogi API
71+
run: |
72+
curl -X POST "https://api.opencatalogi.nl/api/github_events" \
73+
-H "Content-Type: application/json" \
74+
-d '{
75+
"repository": {
76+
"html_url": "'${{ github.event.repository.html_url }}'"
77+
}
78+
}'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
.idea/
3+
_pychache_/

Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Publiccode Action
2-
This GitHub Action automatically generates and updates a publiccode.yaml file in the root of your repository, based on repository metadata. The file is updated each time a push is made to the main branch.
2+
This GitHub Action automatically generates and updates a publiccode.yaml file in the root of your repository, based on repository metadata. The file is updated each time a push is made to the main branch. It is basically a more advanced varsion of [the publiccode softwareversion check](https://github.com/italia/publiccode-softwareversion-check-action/tree/master)
33

44
The Action works by running a Python script that reads repository metadata such as the repository name and description, and uses this information to create or update the publiccode.yaml file.
55

@@ -9,7 +9,7 @@ To use this action, simply include it as a step in your workflow file. No inputs
99
````yaml
1010
steps:
1111
- name: Update publiccode.yaml
12-
uses: OpenCatalogi/publiccode-actionn@v1
12+
uses: OpenCatalogi/publiccode-action@v1
1313
env:
1414
GITHUB_REPOSITORY: ${{ github.repository }}
1515
REPO_DESCRIPTION: "This is a sample repository description"
@@ -26,4 +26,11 @@ None
2626
## Outputs
2727
None
2828

29+
## Architecture
30+
### Why python?
31+
Python is nativly supported by github actions underlaying containers and therefore very quick
32+
33+
### Asumptions
34+
We follow the "get data from teh source" princple
35+
2936
Please note that this action does not handle errors or exceptions while reading metadata or writing to publiccode.yaml. You should ensure that your repository is properly set up to avoid any issues. For example, make sure that your repository name and description are not empty.

action.yaml

Lines changed: 99 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,100 @@
1-
name: 'Update publiccode.yaml'
2-
author: 'Conduction b.v.'
3-
description: 'Updates the publiccode.yaml file with repository metadata'
4-
inputs:
5-
# Define any inputs your action needs here
6-
outputs:
7-
# Define any outputs your action produces here
1+
name: 'Create or Update publiccode.yaml'
2+
author: 'Open Catalogi'
3+
description: 'Creates or updates the publiccode.yaml or publicorganisation.yml file with repository metadata'
4+
5+
branding:
6+
icon: 'file-plus'
7+
color: 'blue'
8+
9+
inputs:
10+
remoterepo:
11+
description: 'Git url of the remote repository you want to check'
12+
required: false
13+
default: ''
14+
publiccode:
15+
description: 'publiccode.yml path'
16+
required: false
17+
default: 'publiccode.yml'
18+
gitname:
19+
description: 'Git name configuration for bump commit'
20+
required: false
21+
default: 'Open Catalogi bot'
22+
gitmail:
23+
description: 'Git mail configuration for bump commit'
24+
required: false
25+
default: 'bot@opencatalogi.nl'
26+
27+
outputs:
28+
version:
29+
description: 'New version of softwareVersion field in publiccode.yml'
30+
releaseDate:
31+
description: 'New release date of releaseDate field in publiccode.yml'
32+
833
runs:
9-
using: 'docker'
10-
image: 'Dockerfile'
34+
using: "composite"
35+
steps:
36+
# Check out the code
37+
- name: Checkout code
38+
uses: actions/checkout@v2
39+
# Install Python
40+
- name: Set up Python
41+
uses: actions/setup-python@v2
42+
with:
43+
python-version: '3.x'
44+
# Transfer the repossitory data to the container
45+
- name: Transfer the repossitory data to the container
46+
run: |
47+
echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV
48+
echo "REPO_DESC=${{ github.event.repository.description }}" >> $GITHUB_ENV
49+
echo "REPO_URL=${{ github.event.repository.html_url }}" >> $GITHUB_ENV
50+
echo "REPO_HOMEPAGE=${{ github.event.repository.homepage }}" >> $GITHUB_ENV
51+
echo "REPO_LICENSE=${{ github.event.repository.license.key }}" >> $GITHUB_ENV
52+
echo "REPO_CREATED_AT=${{ github.event.repository.created_at }}" >> $GITHUB_ENV
53+
54+
echo "ORGANISATION_NAME=${{ github.event.organization.login }}" >> $GITHUB_ENV
55+
echo "ORGANISATION_DESCRIPTION=${{ github.event.organization.description }}" >> $GITHUB_ENV
56+
echo "ORGANISATION_GITID=${{ github.event.organization.id}}" >> $GITHUB_ENV
57+
echo "ORGANISATION_URL=${{ github.event.organization.login }}" >> $GITHUB_ENV
58+
echo "ORGANISATION_AVATAR=${{ github.event.organization.avatar_url }}" >> $GITHUB_ENV
59+
60+
echo "Installing PyYAML..."
61+
pip install PyYAML
62+
# Create changes if it is a normal repository
63+
- name: Create or update the publiccode file
64+
if: (!contains(github.repository, '.github'))
65+
run: python update_publiccode.py
66+
shell: bash
67+
# Create changes if it is an organisation repository
68+
- name: Create or update the publicorganisation file
69+
if: (contains(github.repository, '.github'))
70+
run: python update_publicorganisation.py
71+
shell: bash
72+
# Commit changes if it is a normal repository
73+
- name: Commit changes
74+
if: (!contains(github.repository, '.github'))
75+
run: |
76+
git config --local user.email "action@github.com"
77+
git config --local user.name "GitHub Action"
78+
git add publiccode.yaml
79+
git commit -m "${{ github.workflow }}" || echo "No changes to commit"
80+
git push
81+
# Commit changes if it is an organisation repository
82+
- name: Commit changes
83+
if: (contains(github.repository, '.github'))
84+
run: |
85+
git config --local user.email "action@github.com"
86+
git config --local user.name "GitHub Action"
87+
git add publicorganisation.yaml
88+
git commit -m "${{ github.workflow }}" || echo "No changes to commit"
89+
git push
90+
# Post Repository URL to OpenCatalogi API
91+
- name: Post Repository URL to OpenCatalogi API
92+
run: |
93+
curl -X POST "https://api.opencatalogi.nl/api/github_events" \
94+
-H "Content-Type: application/json" \
95+
-d '{
96+
"repository": {
97+
"html_url": "'${{ github.event.repository.html_url }}'"
98+
}
99+
}'
100+

publiccode.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
categories:
2+
- it-development
3+
description:
4+
en:
5+
apiDocumentation: ''
6+
awards: []
7+
documentation: ''
8+
features: []
9+
genericName: This GitHub Action automatically generates and updates a publiccode.yaml
10+
file in the root of your repository, based on repository metadata. The file
11+
is updated each time a push is made to the main branch.
12+
localisedName: ''
13+
longDescription: ''
14+
screenshots: []
15+
shortDescription: ''
16+
videos: []
17+
developmentStatus: development
18+
landingURL: ''
19+
legal:
20+
authorsFile: ''
21+
license: ''
22+
mainCopyrightOwner: ''
23+
repoOwner: ''
24+
localisation:
25+
availableLanguages:
26+
- en
27+
localisationReady: false
28+
maintenance:
29+
contacts: []
30+
contractors: []
31+
type: none
32+
name: publiccode-action
33+
nl:
34+
vng:
35+
commonground: []
36+
gemma: []
37+
organisation:
38+
description: "E\xE9n centrale plek voor hergebruik van informatietechnologie binnen\
39+
\ de overheid"
40+
logo: https://avatars.githubusercontent.com/u/106239067?v=4
41+
name: OpenCatalogi
42+
url: OpenCatalogi
43+
platforms:
44+
- web
45+
publiccodeYmlVersion: '0.2'
46+
releaseDate: '2023-10-16'
47+
roadmap: ''
48+
softwareType: standalone/web
49+
softwareVersion: ''
50+
url: https://github.com/OpenCatalogi/publiccode-action
51+
usedBy: []

0 commit comments

Comments
 (0)