Skip to content

Duplicates in the resource gallery #97

Duplicates in the resource gallery

Duplicates in the resource gallery #97

name: Update Resource Gallery
on:
issues:
types:
- opened
- edited
jobs:
validate-user-submission:
if: |
github.repository == 'ProjectPythia/projectpythia.github.io'
&& contains(github.event.issue.labels.*.name, 'resource-gallery-submission')
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: Thank you for your contribution
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for your contribution 🎉, @${{ github.actor }}!
We're currently running [validation checks](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to make sure the contents of your submission are okay. An update will be posted here shortly once the validation checks are passing.
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
Thank you for your contribution 🎉, @${{ github.actor }}!
We're currently running [validation checks](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to make sure the contents of your submission are okay. An update will be posted here shortly once the validation checks are passing.
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install pip --upgrade
python -m pip install python-frontmatter markdown-it-py pydantic[email]
- name: Validate input
run: |
python .github/workflows/collect-user-submission.py
- uses: actions/upload-artifact@v2
with:
name: submission
path: resource-gallery-submission-input.json
create-pull-request:
needs: validate-user-submission
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/download-artifact@v2
with:
name: submission
- name: Display structure of downloaded artifacts
run: |
ls -R
- name: Install dependencies
run: |
python -m pip install pip --upgrade
python -m pip install ruamel.yaml pre-commit
- name: Update resource gallery
shell: python
run: |
import yaml
import json
submission_file = 'resource-gallery-submission-input.json'
resource_gallery_file = 'portal/resource_gallery.yaml'
with open(submission_file, 'r') as file:
data = json.load(file)
with open(resource_gallery_file, 'w') as yaml_file:
yaml.dump(data, yaml_file)
- name: Run pre-commit hooks
run: |
python -m pre_commit run --all-files
exit 0
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
commit-message: 'Update resource gallery'
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: resource-gallery-${{ github.event.issue.number }}
title: 'Update resource gallery'
body: |
Update resource gallery as requested in #${{ github.event.issue.number }}. Closes #${{ github.event.issue.number }}.
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: We've created a pull request on your behalf
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: |
@${{ github.actor }}, your submission looks great! We've created a pull request on your behalf using the information you provided.
The pull request can be accessed from this url: ${{ steps.cpr.outputs.pull-request-url }}.
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
@${{ github.actor }}, your submission looks great! We've created a pull request on your behalf using the information you provided.
The pull request can be accessed from this url: ${{ steps.cpr.outputs.pull-request-url }}.