mirror of
https://github.com/konpa/devicon.git
synced 2025-08-06 22:57:02 +02:00
Added working workflow file
This commit is contained in:
8
.github/scripts/build_assets/filehandler.py
vendored
8
.github/scripts/build_assets/filehandler.py
vendored
@@ -230,3 +230,11 @@ def get_added_modified_svgs(files_added_json_path: str,
|
|||||||
svgs.append(path)
|
svgs.append(path)
|
||||||
|
|
||||||
return svgs
|
return svgs
|
||||||
|
|
||||||
|
|
||||||
|
def write_to_file(path: str, value: any):
|
||||||
|
"""
|
||||||
|
Write the value to a JSON file.
|
||||||
|
"""
|
||||||
|
with open(path, "w") as file:
|
||||||
|
file.write(value)
|
||||||
|
6
.github/scripts/build_assets/util.py
vendored
6
.github/scripts/build_assets/util.py
vendored
@@ -2,6 +2,7 @@ from typing import List
|
|||||||
import xml.etree.ElementTree as et
|
import xml.etree.ElementTree as et
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@@ -24,6 +25,8 @@ def check_svgs(svg_file_paths: List[Path]):
|
|||||||
The style must not contain any 'fill' declarations.
|
The style must not contain any 'fill' declarations.
|
||||||
If any error is found, they will be thrown.
|
If any error is found, they will be thrown.
|
||||||
:param: svg_file_paths, the file paths to the svg to check for.
|
:param: svg_file_paths, the file paths to the svg to check for.
|
||||||
|
:return: None if there no errors. If there is, return a JSON.stringified
|
||||||
|
list with the error messages in it.
|
||||||
"""
|
"""
|
||||||
# batch err messages together so user can fix everything at once
|
# batch err messages together so user can fix everything at once
|
||||||
err_msgs = []
|
err_msgs = []
|
||||||
@@ -63,7 +66,8 @@ def check_svgs(svg_file_paths: List[Path]):
|
|||||||
err_msgs.append("\n".join(err_msg))
|
err_msgs.append("\n".join(err_msg))
|
||||||
|
|
||||||
if len(err_msgs) > 0:
|
if len(err_msgs) > 0:
|
||||||
raise Exception("Errors found in these files:\n" + "\n\n".join(err_msgs))
|
return "\n\n".join(err_msgs)
|
||||||
|
return 'None'
|
||||||
|
|
||||||
|
|
||||||
def set_env_var(key: str, value: str, delimiter: str='~'):
|
def set_env_var(key: str, value: str, delimiter: str='~'):
|
||||||
|
14
.github/scripts/check_svgs_on_pr.py
vendored
14
.github/scripts/check_svgs_on_pr.py
vendored
@@ -11,8 +11,8 @@ from build_assets import util
|
|||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
Check the quality of the svgs.
|
Check the quality of the svgs.
|
||||||
If any error is found, set an environmental variable called SVG_ERR_MSGS
|
If any svg error is found, create a json file called 'svg_err_messages.json'
|
||||||
that will contains the error messages.
|
in the root folder that will contains the error messages.
|
||||||
"""
|
"""
|
||||||
args = arg_getters.get_check_svgs_on_pr_args()
|
args = arg_getters.get_check_svgs_on_pr_args()
|
||||||
try:
|
try:
|
||||||
@@ -21,10 +21,14 @@ def main():
|
|||||||
args.files_modified_json_path)
|
args.files_modified_json_path)
|
||||||
print("SVGs to check: ", *svgs, sep='\n')
|
print("SVGs to check: ", *svgs, sep='\n')
|
||||||
|
|
||||||
util.check_svgs(svgs)
|
if len(svgs) == 0:
|
||||||
print("All SVGs found were good. Task completed.")
|
print("No SVGs to check, ending script.")
|
||||||
|
return
|
||||||
|
|
||||||
|
err_messages = util.check_svgs(svgs)
|
||||||
|
filehandler.write_to_file("./svg_err_messages.txt", err_messages)
|
||||||
|
print("Task completed.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
util.set_env_var("SVG_ERR_MSGS", str(e))
|
|
||||||
util.exit_with_err(e)
|
util.exit_with_err(e)
|
||||||
|
|
||||||
|
|
||||||
|
24
.github/workflows/check_svgs_on_pr.yml
vendored
24
.github/workflows/check_svgs_on_pr.yml
vendored
@@ -6,34 +6,40 @@ jobs:
|
|||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Setup Python v3.8
|
|
||||||
uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: python -m pip install --upgrade pip
|
run: python -m pip install --upgrade pip
|
||||||
|
|
||||||
|
- name: Get Changed Files and generate files_added.json & files_modified.json
|
||||||
|
uses: lots0logs/gh-action-get-changed-files@2.1.4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Run the check_svg script
|
- name: Run the check_svg script
|
||||||
run: >
|
run: >
|
||||||
python ./.github/scripts/check_svgs.py ./icomoon.json ./devicon.json ./icons
|
python ./.github/scripts/check_svgs_on_pr.py $HOME/files_added.json $HOME/files_modified.json
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
- name: Upload the err messages
|
- name: Upload the err messages
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
if: success()
|
||||||
with:
|
with:
|
||||||
name: err_messages
|
name: svg_err_messages
|
||||||
path: ./err_messages.txt
|
path: ./svg_err_messages.txt
|
||||||
|
|
||||||
- name: Save the pr num in an artifact
|
- name: Save the pr num in an artifact
|
||||||
shell: bash
|
shell: bash
|
||||||
|
if: success()
|
||||||
env:
|
env:
|
||||||
PR_NUM: ${{ github.event.number }}
|
PR_NUM: ${{ github.event.number }}
|
||||||
run: echo $PR_NUM > pr_num.txt
|
run: echo $PR_NUM > pr_num.txt
|
||||||
|
|
||||||
- name: Upload the pr num
|
- name: Upload the pr num
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
|
if: success()
|
||||||
with:
|
with:
|
||||||
name: pr_num
|
name: pr_num
|
||||||
path: ./pr_num.txt
|
path: ./pr_num.txt
|
||||||
|
51
.github/workflows/post_check_svgs_comment.yml
vendored
51
.github/workflows/post_check_svgs_comment.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Post the screenshots into a comment from Peek Icons workflow
|
name: Post the result of a SVG Check into its PR.
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: ["Check SVGs On PR"]
|
workflows: ['Check SVGs On PR']
|
||||||
types:
|
types:
|
||||||
- completed
|
- completed
|
||||||
jobs:
|
jobs:
|
||||||
@@ -9,9 +9,10 @@ jobs:
|
|||||||
name: Post the screenshot
|
name: Post the screenshot
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- name: Fail the workflow if trigger failed so we can still comment on PR
|
- name: Check if the trigger run worked. If it failed, fail the current run.
|
||||||
if: ${{ github.event.workflow_run.conclusion != 'success' }}
|
# this is done cause this script should only post the err message if trigger run failed
|
||||||
run: echo "::error ::Check SVGs On PR workflow failed. Failing script"
|
if: success() && github.event.workflow_run.conclusion != 'success'
|
||||||
|
uses: cutenode/action-always-fail@v1.0.1
|
||||||
|
|
||||||
- name: Download workflow artifact
|
- name: Download workflow artifact
|
||||||
uses: dawidd6/action-download-artifact@v2.11.0
|
uses: dawidd6/action-download-artifact@v2.11.0
|
||||||
@@ -21,20 +22,22 @@ jobs:
|
|||||||
run_id: ${{ github.event.workflow_run.id }}
|
run_id: ${{ github.event.workflow_run.id }}
|
||||||
|
|
||||||
- name: Get the PR number and save it in $PR_NUM
|
- name: Get the PR number and save it in $PR_NUM
|
||||||
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
echo 'PR_NUM<<EOF' >> $GITHUB_ENV
|
echo 'PR_NUM<<EOF' >> $GITHUB_ENV
|
||||||
cat ./pr_num/pr_num.txt >> $GITHUB_ENV
|
cat ./pr_num/pr_num.txt >> $GITHUB_ENV
|
||||||
echo 'EOF' >> $GITHUB_ENV
|
echo 'EOF' >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Get the error messages and save it in $SVG_ERR_MSGS
|
- name: Read the message file
|
||||||
run: |
|
if: success()
|
||||||
echo 'SVG_ERR_MSGS<<EOF' >> $GITHUB_ENV
|
id: message_reader
|
||||||
cat ./err_messages/err_messages.txt >> $GITHUB_ENV
|
uses: juliangruber/read-file-action@v1.0.0
|
||||||
echo 'EOF' >> $GITHUB_ENV
|
with:
|
||||||
|
path: ./svg_err_messages/svg_err_messages.txt
|
||||||
|
|
||||||
- name: Comment on the PR about the result - Success
|
- name: Comment on the PR about the result - Success
|
||||||
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
||||||
id: create
|
if: success() && steps.message_reader.outputs.content == 'None'
|
||||||
env:
|
env:
|
||||||
MESSAGE: |
|
MESSAGE: |
|
||||||
Hi!
|
Hi!
|
||||||
@@ -50,20 +53,21 @@ jobs:
|
|||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
body: ${{ env.MESSAGE }}
|
body: ${{ env.MESSAGE }}
|
||||||
|
|
||||||
- name: Comment on the PR about the result - Failure
|
- name: Comment on the PR about the result - SVG Error
|
||||||
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
||||||
|
if: success() && steps.message_reader.outputs.content != 'None'
|
||||||
env:
|
env:
|
||||||
MESSAGE: |
|
MESSAGE: |
|
||||||
Hi!
|
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.
|
I'm Devicons' SVG-Checker Bot and it seems we have some issues with your SVGs.
|
||||||
|
|
||||||
Here is what went wrong:
|
Here is what went wrong:
|
||||||
```
|
```
|
||||||
{0}
|
{0}
|
||||||
```
|
```
|
||||||
|
|
||||||
For more reference, check out our [CONTRIBUTING guide](https://github.com/devicons/devicon/blob/develop/CONTRIBUTING.md#svgStandards)
|
For more reference on why these are errors, 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.
|
Please address these issues. When you update this PR, I will check your SVGs again.
|
||||||
|
|
||||||
@@ -71,6 +75,25 @@ jobs:
|
|||||||
SVG-Checker Bot :smile:
|
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.
|
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, steps.message_reader.outputs.content) }}
|
||||||
|
|
||||||
|
- name: Comment on the PR about the result - Failure
|
||||||
|
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
||||||
|
if: failure() || cancelled()
|
||||||
|
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.
|
||||||
|
|
||||||
|
Please let my maintainers know of the issues. They will take a look at my work and try to resolve the problem. Until then, please hang tight and sorry for the inconvenience.
|
||||||
|
|
||||||
|
Cheers,
|
||||||
|
SVG-Checker Bot :smile:
|
||||||
with:
|
with:
|
||||||
type: create
|
type: create
|
||||||
issue_number: ${{ env.PR_NUM }}
|
issue_number: ${{ env.PR_NUM }}
|
||||||
|
19
.github/workflows/post_peek_screenshot.yml
vendored
19
.github/workflows/post_peek_screenshot.yml
vendored
@@ -1,7 +1,7 @@
|
|||||||
name: Post the screenshots into a comment from Peek Icons workflow
|
name: Post the screenshots into a comment from Peek Icons workflow
|
||||||
on:
|
on:
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: ["Peek Icons"]
|
workflows: ['Peek Icons']
|
||||||
types:
|
types:
|
||||||
- completed
|
- completed
|
||||||
jobs:
|
jobs:
|
||||||
@@ -9,9 +9,9 @@ jobs:
|
|||||||
name: Post the screenshot
|
name: Post the screenshot
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- name: Fail the workflow if trigger failed so we can still comment on PR
|
- name: Check if the trigger run worked. If not, fail the current run.
|
||||||
if: ${{ github.event.workflow_run.conclusion != 'success' }}
|
if: github.event.workflow_run.conclusion != 'success'
|
||||||
run: echo "::error ::Peek Icons workflow failed. Failing script"
|
uses: cutenode/action-always-fail@v1.0.1
|
||||||
|
|
||||||
- name: Download workflow artifact
|
- name: Download workflow artifact
|
||||||
uses: dawidd6/action-download-artifact@v2.11.0
|
uses: dawidd6/action-download-artifact@v2.11.0
|
||||||
@@ -28,14 +28,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload screenshot of the newly made icons gotten from the artifacts
|
- name: Upload screenshot of the newly made icons gotten from the artifacts
|
||||||
id: icons_overview_img_step
|
id: icons_overview_img_step
|
||||||
uses: devicons/public-upload-to-imgur@v2.2.0
|
uses: devicons/public-upload-to-imgur@v2.2.1
|
||||||
with:
|
with:
|
||||||
path: ./screenshots/new_icons.png
|
path: ./screenshots/new_icons.png
|
||||||
client_id: ${{secrets.IMGUR_CLIENT_ID}}
|
client_id: ${{secrets.IMGUR_CLIENT_ID}}
|
||||||
|
|
||||||
- name: Upload zoomed in screenshot of the newly made icons gotten from the artifacts
|
- name: Upload zoomed in screenshot of the newly made icons gotten from the artifacts
|
||||||
id: icons_detailed_img_step
|
id: icons_detailed_img_step
|
||||||
uses: devicons/public-upload-to-imgur@v2.2.0
|
uses: devicons/public-upload-to-imgur@v2.2.1
|
||||||
if: success()
|
if: success()
|
||||||
with:
|
with:
|
||||||
path: ./screenshots/screenshot_*.png
|
path: ./screenshots/screenshot_*.png
|
||||||
@@ -43,9 +43,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Comment on the PR about the result - Success
|
- name: Comment on the PR about the result - Success
|
||||||
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
||||||
|
if: success()
|
||||||
env:
|
env:
|
||||||
OVERVIEW_IMG_URL: ${{ fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0] }}
|
OVERVIEW_IMG_MARKDOWN: ${{ fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0] }}
|
||||||
DETAILED_IMGS_URL: ${{ join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '\n') }}
|
DETAILED_IMGS_MARKDOWN: ${{ join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '\n') }}
|
||||||
MESSAGE: |
|
MESSAGE: |
|
||||||
Hi there,
|
Hi there,
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ jobs:
|
|||||||
body: ${{format(env.MESSAGE, env.OVERVIEW_IMG_MARKDOWN, env.DETAILED_IMGS_MARKDOWN)}}
|
body: ${{format(env.MESSAGE, env.OVERVIEW_IMG_MARKDOWN, env.DETAILED_IMGS_MARKDOWN)}}
|
||||||
|
|
||||||
- name: Comment on the PR about the result - Failure
|
- name: Comment on the PR about the result - Failure
|
||||||
if: failure()
|
if: failure() || cancelled()
|
||||||
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
uses: jungwinter/comment@v1 # let us comment on a specific PR
|
||||||
env:
|
env:
|
||||||
MESSAGE: |
|
MESSAGE: |
|
||||||
|
Reference in New Issue
Block a user