Skip to content

Commit ec607da

Browse files
committed
workflow
1 parent 22c1dc2 commit ec607da

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Automatic Pull request
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
title:
7+
description: 'title of example'
8+
required: true
9+
body:
10+
description: 'description of example'
11+
required: true
12+
upstreamRepo:
13+
description: 'Upstream repo'
14+
required: true
15+
botRepo:
16+
description: 'bot repo'
17+
required: true
18+
repo:
19+
description: 'repo name'
20+
required: true
21+
22+
jobs:
23+
create-pull-request:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Create PR
28+
run: |
29+
gh pr create --repo ${{ github.event.inputs.upstreamRepo }}/${{ github.event.inputs.repo }} --head ${{ github.event.inputs.botRepo }}:${{ github.ref }} --base main --title "${{ github.event.inputs.title }}" --body "${{ github.event.inputs.body }}"
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.token }}

contribute.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@
44

55
# Intializing the Variables
66
# Hashed token
7-
BOT_TOKEN = 'Z2l0aHViX3BhdF8xMUFYM1pBT1kwR0lTTm5jWFlObXdhX3hQa2xyOVdSZ0ZMRURGcERFNFBzbW9zZFFUTzZaNTBBZkcwY2dYSVNKZ2FCSUtNWUo3SGpXTnlxTFda'
8-
REPO_NAME = 'concore' #repo-name
9-
OWNER_NAME = 'parteekcoder' #bot
7+
BOT_TOKEN = 'Z2l0aHViX3BhdF8xMUFYS0pGVFkwUWVWZ3AzbkpkWk8yX3BOc1VncDFIVDMwZVNXcHhBNm9acHhMaGZGdU5CdE85TGpqdXF1UWRRNzI2S01aUk5HRUNGanFWNDZi'
8+
REPO_NAME = 'concore' #repo name
9+
OWNER_NAME = 'parteekcoder123' #bot account name
1010
STUDY_NAME = sys.argv[1]
1111
STUDY_NAME_PATH = sys.argv[2]
1212
AUTHOR_NAME = sys.argv[3]
1313
BRANCH_NAME = sys.argv[4]
1414
PR_TITLE = sys.argv[5]
1515
PR_BODY = sys.argv[6]
16-
17-
# if author name has spaces
18-
DIR_PATH = AUTHOR_NAME + '_' + STUDY_NAME
19-
UPSTREAM_OWNER = 'parteekcoder123'
16+
UPSTREAM_OWNER = 'parteekcoder' # upstream to which examples should be contributed
2017

2118

2219
# Defining Functions
@@ -80,7 +77,7 @@ def fetchUpstream(repo,base_sha,branch):
8077
def runWorkflow(repo,upstream_repo):
8178
openPR = anyOpenPR(upstream_repo)
8279
if openPR==None:
83-
workflow_runned = repo.get_workflow(id_or_name="pull_request.yml").create_dispatch(ref=BRANCH_NAME,inputs={'title':PR_TITLE,'body':PR_BODY})
80+
workflow_runned = repo.get_workflow(id_or_name="pull_request.yml").create_dispatch(ref=BRANCH_NAME,inputs={'title':PR_TITLE,'body':PR_BODY,'upstreamRepo':upstream_repo,'botRepo':OWNER_NAME,'repo':REPO_NAME})
8481
if not workflow_runned:
8582
print("Some Error Occured.Please try after some time")
8683
exit(0)
@@ -133,6 +130,8 @@ def decode_token(encoded_token):
133130
PR_TITLE="Contributing Study "+AUTHOR_NAME+" "+STUDY_NAME
134131
if PR_BODY=="#":
135132
PR_BODY="Study Contributed by "+ AUTHOR_NAME
133+
AUTHOR_NAME = AUTHOR_NAME.replace(" ","_")
134+
DIR_PATH = AUTHOR_NAME + '_' + STUDY_NAME
136135
g = Github(decode_token(BOT_TOKEN))
137136
repo = g.get_user(OWNER_NAME).get_repo(REPO_NAME)
138137
upstream_repo = g.get_repo(f'{UPSTREAM_OWNER}/{REPO_NAME}') #controlcore-Project/concore

0 commit comments

Comments
 (0)