Skip to content

Commit

Permalink
Updated the github_env to accomodate ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Boi committed Jan 8, 2021
1 parent 42047d9 commit 1c166eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
25 changes: 17 additions & 8 deletions .github/scripts/build_assets/github_env.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
import os
import platform


def set_env_var(key: str, value: str, delimiter: str='~'):
"""
Set the GitHub env variable of 'key' to 'value' using
the method specified here:
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
Support both Windows and Ubuntu machines provided by GitHub Actions.
Note: This assumes that we are on a Windows machine.
:param: key, the name of the env variable.
:param: value, the value of the env variable.
:param: delimiter, the delimiter that you want to use
to write to the file. Only applicable if the 'value' contains
'\n' character aka a multiline string.
"""
print('echo "{key}={value}" >> %GITHUB_ENV%')

if "\n" in value:
os.system(f'echo "{key}<<{delimiter}" >> %GITHUB_ENV%')
os.system(f'echo {value} >> %GITHUB_ENV%')
os.system(f'echo "{delimiter}" >> %GITHUB_ENV%')
if platform.system() == "Windows":
if "\n" in value:
os.system(f'echo "{key}<<{delimiter}" >> %GITHUB_ENV%')
os.system(f'echo "{value}" >> %GITHUB_ENV%')
os.system(f'echo "{delimiter}" >> %GITHUB_ENV%')
else:
os.system(f'echo "{key}={value}" >> %GITHUB_ENV%')
elif platform.system() == "Linux":
if "\n" in value:
os.system(f'echo "{key}<<{delimiter}" >> $GITHUB_ENV')
os.system(f'echo "{value}" >> $GITHUB_ENV')
os.system(f'echo "{delimiter}" >> $GITHUB_ENV')
else:
os.system(f'echo "{key}={value}" >> $GITHUB_ENV')
else:
os.system(f'echo "{key}={value}" >> %GITHUB_ENV%')
raise Exception("This function doesn't support this platform: " + platform.system())
5 changes: 5 additions & 0 deletions .github/scripts/check_svgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


def main():
"""
Check the quality of the svgs.
If any error is found, set an environmental variable called ERR_MSGS
that will contains the error messages.
"""
args = arg_getters.get_check_svgs_args()
new_icons = filehandler.find_new_icons(args.devicon_json_path, args.icomoon_json_path)

Expand Down

0 comments on commit 1c166eb

Please sign in to comment.