Skip to content

Author names on the gallery cards #60

Author names on the gallery cards

Author names on the gallery cards #60

name: Update Cookbook Gallery
on:
issues:
types:
- opened
- edited
jobs:
validate-user-submission:
if: github.repository == 'ProjectPythia/cookbook-gallery' && contains(github.event.issue.labels.*.name, 'cookbook-gallery-submission')
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
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@v3
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@v3
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@v3
- uses: actions/setup-python@v4
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@v3
with:
name: submission
path: cookbook-submission-input.txt
create-pull-request:
needs: validate-user-submission
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
- uses: actions/download-artifact@v3
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 cookbook gallery
shell: python
run: |
from ruamel.yaml import YAML
yaml = YAML()
submission_file = 'cookbook-submission-input.txt'
cookbook_gallery_file = 'site/cookbook_gallery.txt'
with open(submission_file) as f:
repo = f.read().strip()
with open(cookbook_gallery_file) as f:
cookbook_gallery = f.readlines()
with open(cookbook_gallery_file, 'w') as f:
cookbook_gallery.append(repo)
f.writelines(cookbook_gallery)
- name: Run pre-commit hooks
run: |
python -m pre_commit run --all-files
exit 0
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: 'Update cookbook gallery'
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
base: main
title: 'Update cookbook gallery per #${{ github.event.issue.number }}'
body: |
Update cookbook gallery as requested in #${{ github.event.issue.number }}. Closes #${{ github.event.issue.number }}.
token: ${{ steps.generate-token.outputs.token }}
branch: cookbook-gallery-${{ github.event.issue.number }}
- name: Find Comment
uses: peter-evans/find-comment@v2
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@v3
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@v3
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 }}.