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