Skip to content

Commit

Permalink
update workflows auto-create-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno-sole committed Feb 27, 2023
1 parent 7bffca7 commit f72ed5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
32 changes: 23 additions & 9 deletions .github/workflows/auto-create-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
shell: python
env:
GITHUB_TOKEN: ${{ steps.get-token.outputs.app_token }}
CHANGE_ID: ${{ github.event.pull_request.number }}
run: |
import requests
import yaml
Expand All @@ -67,23 +68,35 @@ jobs:
"Accept": "application/vnd.github+json",
"Authorization":"Bearer " + os.environ.get("GITHUB_TOKEN")
}
header1 = {
"Accept": "application/vnd.github.v3.diff"
}
create_repo_url = 'https://api.github.com/repos/deepin-community/template-repository/generate'
def set_output(name, value):
output_file = os.environ.get("GITHUB_OUTPUT")
with open(output_file, "w") as output:
output.write(name + "=" + value + "\n")
def read_yml():
with open("repos.yml", "r+") as intergration_file:
return yaml.load(intergration_file, Loader=yaml.BaseLoader)
def get_pr_diff():
res = requests.get("https://api.github.com/repos/deepin-community/SIG/pulls/" + os.environ.get("CHANGE_ID") ,headers = header1)
data = res.text
f = open("diff","w")
f.write(data)
f.close()
reponame = os.popen("cat diff | grep '+ - repo:'| awk '{print $4}' ").read()
data1 = str(reponame)
data1 = data1.split('\n')
print(data1)
return data1
def check_repo(repo):
res = requests.get("https://api.github.com/repos/deepin-community/{repo}".format(repo=repo))
print("check_repo ",res.text)
if res.status_code == 200:
return repo
def create_repo(repo):
data_repo = {
'owner':'deepin-community',
Expand All @@ -98,12 +111,13 @@ jobs:
os.popen('''osc ci -m "init"''').read()
try:
data = read_yml()
data = get_pr_diff()
os.chdir("deepin:Develop:community")
for repo in data.get("repos"):
print(repo.get('repo'))
if check_repo(repo.get('repo')) == None:
create_repo(repo.get('repo'))
for repo in data:
if repo != '':
print(repo)
if check_repo(repo) == None:
create_repo(repo)
except BaseException as e:
logging.error(e)
exit(-10)
Expand Down
2 changes: 1 addition & 1 deletion repos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ repos:

- repo: brise
group: deepin-sysdev-team
info: Rime Input Method Engine, the schema data RIME is the acronym of Rime Input Method Engine.
info: Rime Input Method Engine, the schema data RIME is the acronym of Rime Input Method Engine.

0 comments on commit f72ed5d

Please sign in to comment.