Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathentrypoint.py
More file actions
Latest commit
executable file
·58 lines (53 loc) · 2.13 KB
/
Copy pathentrypoint.py
File metadata and controls
executable file
·58 lines (53 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
fromplumbumimportlocal
importos
defdebug(message: str):
print(f'##[debug]{message}')
defrun():
netrc_path=os.path.join(local.env.get('HOME', ''), '.netrc')
github_actor=local.env.get('GITHUB_ACTOR')
github_token=local.env.get('INPUT_GITHUB-TOKEN')
commit_message=local.env.get('INPUT_COMMIT-MESSAGE')
force_add=local.env.get('INPUT_FORCE-ADD')
force_push=local.env.get('INPUT_FORCE-PUSH')
branch=local.env.get('INPUT_PUSH-BRANCH') or"/".join(local.env.get('GITHUB_REF').split('/')[2:])
rebase=local.env.get('INPUT_REBASE', 'false')
files=local.env.get('INPUT_FILES', '')
email=local.env.get('INPUT_EMAIL', f'{github_actor}@users.noreply.github.com')
name=local.env.get('INPUT_NAME', github_actor)
withopen(netrc_path, 'w') asf:
f.write(
f'machine github.com\n'
f'login {github_actor}\n'
f'password {github_token}\n'
f'machine api.github.com\n'
f'login {github_actor}\n'
f'password {github_token}\n'
)
chmod=local['chmod']
git=local['git']
debug(chmod(['600', netrc_path]))
debug(git(['config', '--global', 'user.email', email]))
debug(git(['config', '--global', 'user.name', name]))
debug(git(['config', '--global', '--add', 'safe.directory', '/github/workspace']))
debug(f'username:{github_actor}, branch:{branch}, commit message:{commit_message}')
withopen(netrc_path) asf:
debug(f.read())
add_args= ['add']
ifforce_add=='true':
add_args.append('-f')
add_args.append('-A')
iffiles:
debug(f"Files: {files}")
add_args.extend(files.strip("'").split())
ifrebase=='true':
debug(git(['pull', '--rebase', '--autostash', 'origin', branch]))
push_args= ['push', '--follow-tags', '--set-upstream', 'origin', branch]
ifforce_push=='true':
push_args.append('--force')
debug(git(['checkout', '-B', branch]))
debug(git(add_args))
debug(git(['commit', '-m', commit_message], retcode=None))
debug(git(push_args))
if__name__=='__main__':
run()