mirror of
https://github.com/RROrg/rr.git
synced 2025-09-23 04:07:04 +08:00
优化 GitHub Actions 脚本,改进环境变量设置逻辑
This commit is contained in:
parent
59112312c6
commit
38caa773d7
89
.github/workflows/issues.yml
vendored
89
.github/workflows/issues.yml
vendored
@ -27,68 +27,51 @@ jobs:
|
|||||||
shell: python
|
shell: python
|
||||||
run: |
|
run: |
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import json, subprocess
|
import json
|
||||||
def set_output(name, value):
|
import os
|
||||||
subprocess.call(f'echo "{name}<<EOF" >> $GITHUB_ENV', shell=True)
|
|
||||||
subprocess.call(f'echo "{value}" >> $GITHUB_ENV', shell=True)
|
|
||||||
subprocess.call(f'echo "EOF" >> $GITHUB_ENV', shell=True)
|
|
||||||
|
|
||||||
issuetitle = ${{ toJSON(github.event.issue.title) }}
|
def set_env(name, value):
|
||||||
issuebody = ${{ toJSON(github.event.issue.body) }}
|
with open(os.environ['GITHUB_ENV'], 'a', encoding='utf-8') as f:
|
||||||
|
f.write(f'{name}={value}\n')
|
||||||
|
|
||||||
|
issuetitle = """${{ github.event.issue.title }}"""
|
||||||
|
issuebody = """${{ github.event.issue.body }}"""
|
||||||
|
|
||||||
iscustom = 'false'
|
iscustom = 'false'
|
||||||
warinfo = 'false'
|
warinfo = 'false'
|
||||||
|
|
||||||
format = ''
|
fields = {
|
||||||
size = ''
|
"format": "",
|
||||||
template = ''
|
"size": "",
|
||||||
language= ''
|
"template": "",
|
||||||
sn = ''
|
"language": "",
|
||||||
macs = ''
|
"sn": "",
|
||||||
tips = ''
|
"macs": "",
|
||||||
model = ''
|
"tips": "",
|
||||||
version = ''
|
"model": "",
|
||||||
kernel = ''
|
"version": "",
|
||||||
addons = ''
|
"kernel": "",
|
||||||
modules = ''
|
"addons": "",
|
||||||
|
"modules": ""
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if issuetitle.lower().startswith('custom'):
|
if issuetitle.strip().lower().startswith('custom'):
|
||||||
jsonbody = json.loads(issuebody)
|
jsonbody = json.loads(issuebody)
|
||||||
iscustom = 'true'
|
iscustom = 'true'
|
||||||
format = jsonbody.get('format', '')
|
for k in fields:
|
||||||
size = jsonbody.get('size', '')
|
fields[k] = jsonbody.get(k, "")
|
||||||
template = jsonbody.get('template', '')
|
except Exception:
|
||||||
language = jsonbody.get('language', '')
|
pass
|
||||||
sn = jsonbody.get('sn', '')
|
|
||||||
macs = jsonbody.get('macs', '')
|
|
||||||
tips = jsonbody.get('tips', '')
|
|
||||||
model = jsonbody.get('model', '')
|
|
||||||
version = jsonbody.get('version', '')
|
|
||||||
kernel = jsonbody.get('kernel', '')
|
|
||||||
addons = jsonbody.get('addons', '')
|
|
||||||
modules = jsonbody.get('modules', '')
|
|
||||||
except ValueError as e:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if iscustom == 'false':
|
if iscustom == 'false':
|
||||||
if issuebody.find('DMI') < 0 and issuebody.find('CPU') < 0 and issuebody.find('NIC') < 0:
|
if not any(x in issuebody for x in ['DMI', 'CPU', 'NIC']):
|
||||||
warinfo = 'true'
|
warinfo = 'true'
|
||||||
|
|
||||||
set_output("iscustom", iscustom)
|
set_env("iscustom", iscustom)
|
||||||
set_output("warinfo", warinfo)
|
set_env("warinfo", warinfo)
|
||||||
|
for k, v in fields.items():
|
||||||
set_output("format", format)
|
set_env(k, v)
|
||||||
set_output("size", size)
|
|
||||||
set_output("template", template)
|
|
||||||
set_output("language", language)
|
|
||||||
set_output("sn", sn)
|
|
||||||
set_output("macs", macs)
|
|
||||||
set_output("tips", tips)
|
|
||||||
set_output("model", model)
|
|
||||||
set_output("version", version)
|
|
||||||
set_output("kernel", kernel)
|
|
||||||
set_output("addons", addons)
|
|
||||||
set_output("modules", modules)
|
|
||||||
|
|
||||||
- name: Update Comment Warinfo
|
- name: Update Comment Warinfo
|
||||||
if: env.warinfo == 'true'
|
if: env.warinfo == 'true'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user