1
0
mirror of https://github.com/konpa/devicon.git synced 2025-07-30 11:20:15 +02:00

Redo the workflow archs so we can comment on pr

This commit is contained in:
Thomas Bui
2021-01-10 16:38:53 -08:00
parent 2e49bfa1e1
commit 5bcd269f00
6 changed files with 233 additions and 76 deletions

View File

@@ -6,29 +6,34 @@ jobs:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Setup Python v3.8
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies (python, pip, npm)
run: |
python -m pip install --upgrade pip
pip install -r ./.github/scripts/requirements.txt
npm install
- name: Executing build and create fonts via icomoon
run: >
python ./.github/scripts/icomoon_build.py
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe ./icomoon.json
./devicon.json ./icons ./ --headless
- name: Upload geckodriver.log for debugging purposes
uses: actions/upload-artifact@v2
if: failure()
with:
name: geckodriver-log
path: ./geckodriver.log
- name: Build devicon.min.css
if: success()
run: npm run build-css
- name: Upload screenshot of the newly made icons
id: imgur_step
uses: devicons/public-upload-to-imgur@v2.1.1
@@ -36,6 +41,7 @@ jobs:
with:
path: ./new_icons.png
client_id: ${{secrets.IMGUR_CLIENT_ID}}
- name: Create Pull Request
if: success()
uses: peter-evans/create-pull-request@v3

View File

@@ -7,29 +7,36 @@ jobs:
name: Check the SVGs' quality in the `develop` branch
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
ref: develop
- name: Setup Python v3.8
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install --upgrade pip
- name: Run the check_svg script
run: >
python ./.github/scripts/check_svgs_monthly.py ./devicon.json ./icons
check_master:
name: Check the SVGs' quality in the `master` branch
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2 # check out default branch, which is master
- name: Setup Python v3.8
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install --upgrade pip
- name: Run the check_svg script
run: >
python ./.github/scripts/check_svgs.py ./icomoon.json ./devicon.json ./icons
python ./.github/scripts/check_svgs.py ./icomoon.json ./devicon.json ./icons

View File

@@ -1,65 +1,39 @@
name: Check SVGs On PR
on:
pull_request:
paths:
- '**.svg' # runs only when a svg is added in the PR
on: pull_request
jobs:
check:
name: Check the SVGs' quality
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2 # check out the merge branch of the PR and base
- uses: actions/checkout@v2
- name: Setup Python v3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: python -m pip install --upgrade pip
- name: Find files added in this PR
uses: lots0logs/gh-action-get-changed-files@2.1.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run the check_svg script
shell: bash
run: >
python ./.github/scripts/check_svgs_on_pr.py $HOME/files_added.json $HOME/files_modified.json
- name: Comment on the PR about the result - Success
if: success()
uses: NejcZdovc/comment-pr@v1.1.1
env:
MESSAGE: |
Hi!
I'm Devicons' SVG-Checker Bot and I just checked all the SVGs in this branch.
python ./.github/scripts/check_svgs.py ./icomoon.json ./devicon.json ./icons
Everything looks great. Good job!
- name: Save the error messages in an artifact
shell: bash
run: echo $SVG_ERR_MSGS > err_messages.txt # the $SVG_ERR_MSGS is set by the python script above
Have a nice day,
SVG-Checker Bot :grin:
- name: Upload the err messages
uses: actions/upload-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: ${{ env.MESSAGE }}
- name: Comment on the PR about the result - Failed
if: failure()
uses: NejcZdovc/comment-pr@v1.1.1
name: err_messages
path: ./err_messages.txt
- name: Save the pr num in an artifact
shell: bash
env:
MESSAGE: |
Hi!
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
I'm Devicons' SVG-Checker Bot and it seems we've ran into a problem. I'm supposed to check your svgs but I couldn't do my task due to an issue.
Here is what went wrong:
```
{0}
```
For more reference, check out our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards)
Please address these issues. When you update this PR, I will check your SVGs again.
Thanks for your help,
SVG-Checker Bot :smile:
PS. One day, I will be smart enough to fix these errors for you :persevere:. Until then, I can only point them out.
- name: Upload the pr num
uses: actions/upload-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
message: ${{ format(env.MESSAGE, env.SVG_ERR_MSGS)}}
name: pr_num
path: ./pr_num.txt

View File

@@ -5,18 +5,21 @@ on:
jobs:
build:
name: Peek Icons
if: contains(github.event.pull_request.labels.*.name, 'bot:peek')
if: github.event.label.name == 'bot:peek'
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Setup Python v3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r ./.github/scripts/requirements.txt
- name: Run icomoon_peek.py
env:
PR_TITLE: ${{ github.event.pull_request.title }}
@@ -25,37 +28,29 @@ jobs:
python ./.github/scripts/icomoon_peek.py
./.github/scripts/build_assets/geckodriver-v0.27.0-win64/geckodriver.exe ./icomoon.json
./devicon.json ./icons ./ --headless --pr_title "%PR_TITLE%"
- name: Upload screenshots for comments
uses: actions/upload-artifact@v2
if: success()
with:
name: screenshots
path: ./screenshots/*.png
- name: Save the pr num in an artifact
shell: bash
env:
PR_NUM: ${{ github.event.number }}
run: echo $PR_NUM > pr_num.txt
- name: Upload the pr num
uses: actions/upload-artifact@v2
with:
name: pr_num
path: ./pr_num.txt
- name: Upload geckodriver.log for debugging purposes
uses: actions/upload-artifact@v2
if: failure()
with:
name: geckodriver-log
path: ./geckodriver.log
- name: Comment on the PR about the result
if: failure()
uses: github-actions-up-and-running/pr-comment@v1.0.1
env:
MESSAGE: |
~Hi
I'm Devicons' Peek Bot and it seems we've ran into a problem (sorry!).
Please double check and fix the possible issues below:
- Your svgs are named and added correctly to the /icons folder as seen [here](https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#orgGuidelines).
- Your icon information has been added to the `devicon.json` as seen [here](https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#updateDevicon)
- Your PR title follows the format seen [here](https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#overview)
Once everything is fixed, I will try. If I still fail (sorry!), the maintainers will investigate further.
Best of luck,
Peek Bot :relaxed:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
message: ${{env.MESSAGE}}
path: ./geckodriver.log

View File

@@ -0,0 +1,78 @@
name: Post the screenshots into a comment from Peek Icons workflow
on:
workflow_run:
workflows: ["Check SVGs On PR"]
types:
- completed
jobs:
post_screenshots_in_comment:
name: Post the screenshot
runs-on: ubuntu-18.04
steps:
- name: Fail the workflow if trigger failed so we can still comment on PR
if: ${{ github.event.workflow_run.conclusion != 'success' }}
run: echo "::error ::Check SVGs On PR workflow failed. Failing script"
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.11.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: peek_icons.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Get the PR number and save it in $PR_NUM
run: |
echo 'PR_NUM<<EOF' >> $GITHUB_ENV
cat ./pr_num/pr_num.txt >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Get the error messages and save it in $SVG_ERR_MSGS
run: |
echo 'SVG_ERR_MSGS<<EOF' >> $GITHUB_ENV
cat ./err_messages/err_messages.txt >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Comment on the PR about the result - Success
uses: jungwinter/comment@v1 # let us comment on a specific PR
id: create
env:
MESSAGE: |
Hi!
I'm Devicons' SVG-Checker Bot and I just checked all the SVGs in this branch.
Everything looks great. Good job!
Have a nice day,
SVG-Checker Bot :grin:
with:
type: create
issue_number: ${{ env.PR_NUM }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ env.MESSAGE }}
- name: Comment on the PR about the result - Failure
uses: jungwinter/comment@v1 # let us comment on a specific PR
env:
MESSAGE: |
Hi!
I'm Devicons' SVG-Checker Bot and it seems we've ran into a problem. I'm supposed to check your svgs but I couldn't do my task due to an issue.
Here is what went wrong:
```
{0}
```
For more reference, check out our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards)
Please address these issues. When you update this PR, I will check your SVGs again.
Thanks for your help,
SVG-Checker Bot :smile:
PS. One day, I will be smart enough to fix these errors for you :persevere:. Until then, I can only point them out.
with:
type: create
issue_number: ${{ env.PR_NUM }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ format(env.MESSAGE, env.SVG_ERR_MSGS)}}

View File

@@ -0,0 +1,97 @@
name: Post the screenshots into a comment from Peek Icons workflow
on:
workflow_run:
workflows: ["Peek Icons"]
types:
- completed
jobs:
post_screenshots_in_comment:
name: Post the screenshot
runs-on: ubuntu-18.04
steps:
- name: Fail the workflow if trigger failed so we can still comment on PR
if: ${{ github.event.workflow_run.conclusion != 'success' }}
run: echo "::error ::Peek Icons workflow failed. Failing script"
- name: Download workflow artifact
uses: dawidd6/action-download-artifact@v2.11.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: peek_icons.yml
run_id: ${{ github.event.workflow_run.id }}
- name: Get the PR number and save it in $PR_NUM
run: |
echo 'PR_NUM<<EOF' >> $GITHUB_ENV
cat ./pr_num/pr_num.txt >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Upload screenshot of the newly made icons gotten from the artifacts
id: icons_overview_img_step
uses: devicons/public-upload-to-imgur@v2.2.0
with:
path: ./screenshots/new_icons.png
client_id: ${{secrets.IMGUR_CLIENT_ID}}
- name: Upload zoomed in screenshot of the newly made icons gotten from the artifacts
id: icons_detailed_img_step
uses: devicons/public-upload-to-imgur@v2.2.0
if: success()
with:
path: ./screenshots/screenshot_*.png
client_id: ${{secrets.IMGUR_CLIENT_ID}}
- name: Comment on the PR about the result - Success
uses: jungwinter/comment@v1 # let us comment on a specific PR
env:
OVERVIEW_IMG_URL: ${{ fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0] }}
DETAILED_IMGS_URL: ${{ join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '\n') }}
MESSAGE: |
Hi there,
I'm Devicons' Peek Bot and I just peeked at the icons that you wanted to add using [icomoon.io](https://icomoon.io/app/#/select).
Here is the result below:
![Peeked Icons (top left)]({0})
Here are the zoomed-in screenshots of the added icons:
{1}
Note: If the images don't show up, it's probably because it has been autodeleted by Imgur after 6 months due to our API choice.
**The maintainers will now take a look at it and decide whether to merge your PR.**
Thank you for contributing to Devicon! I hope everything works out and your icons are accepted into the repo.
Cheers,
Peek Bot :blush:
with:
type: create
issue_number: ${{ env.PR_NUM }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{format(env.MESSAGE, env.OVERVIEW_IMG_MARKDOWN, env.DETAILED_IMGS_MARKDOWN)}}
- name: Comment on the PR about the result - Failure
if: failure()
uses: jungwinter/comment@v1 # let us comment on a specific PR
env:
MESSAGE: |
Hi there,
I'm Devicons' Peek Bot and it seems we've ran into a problem (sorry!).
Please double check and fix the possible issues below:
- Your svgs are named and added correctly to the /icons folder as seen [here](https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#orgGuidelines).
- Your icon information has been added to the `devicon.json` as seen [here](https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#updateDevicon)
- Your PR title follows the format seen [here](https://github.com/devicons/devicon/blob/master/CONTRIBUTING.md#overview)
Once everything is fixed, I will try. If I still fail (sorry!), the maintainers will investigate further.
Best of luck,
Peek Bot :relaxed:
with:
type: create
issue_number: ${{ env.PR_NUM }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ env.MESSAGE }}