Merge pull request #3 from OpenCatalogi/feature/OP-92/add-repository-… #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}'" | |
} | |
}' |