-
Notifications
You must be signed in to change notification settings - Fork 19
148 lines (127 loc) · 5.16 KB
/
update-resource-gallery.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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 <[email protected]>
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 }}.