|
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 | + |
8 | 33 | 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 | +
|
0 commit comments