Skip to content

Commit abe36e7

Browse files
authored
Merge branch 'master' into 1-status-url
2 parents 256c570 + 2b85ef8 commit abe36e7

File tree

4 files changed

+38
-13
lines changed

4 files changed

+38
-13
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ API_TOKEN=YOUR_GITHUB_SECRET
2727
└── my-site.json
2828
```
2929

30-
```json
30+
```js
3131
my-site.json
3232

3333
{
34-
"path": "/home/code/my-site", # path where repository lives
35-
"cwd": "/home/user", # user path for nvm
36-
"node": "v12.7.0", # nvm node version to use, if .nvmrc is no supplied
34+
"path": "/home/code/my-site", // path where repository lives
35+
"cwd": "/home/user", // user path for nvm
36+
"node": "v12.7.0", // nvm node version to use, if .nvmrc is no supplied
3737
"release": {
38-
"build": "yarn && yarn build",
38+
"build": "yarn && yarn build && tar -xvf {{release.sha}}.tar.gz", // you may use handlebar notation to inject GitHub payload values into your steps
3939
"deploy": "rsync -av --delete public/ /var/www/html/my-site",
4040
"cleanup": "rm -rf node_modules/ && rm -rf .cache/ && yarn cache clean"
4141
}
@@ -44,7 +44,9 @@ my-site.json
4444

4545
### Adding listener to GitHub Webhooks
4646

47-
As of `v0.2.0` - Only the `release` event is supported.
47+
` - Only the `release` event is supported.
48+
=======
49+
As of `v0.2.1` - Only the `release` event is supported.
4850

4951
`https://{domain}/webhooks/{repo}`
5052
or
@@ -80,4 +82,4 @@ Within your Apache2 `.conf`
8082
```bash
8183
ProxyPass /webhooks http://localhost:5000/webhooks
8284
ProxyPassReverse /webhooks https://localhost:5000/webhooks
83-
```
85+
```

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name="github-webhooks-listener",
11-
version="0.2.0",
11+
version="0.2.1",
1212
author="Matt Suhay",
1313
author_email="matt@suhay.dev",
1414
description="A simple listener that will trigger custom scripts when it receives events from GitHub.",
@@ -26,7 +26,8 @@
2626
],
2727
install_requires=[
2828
'quart',
29-
'python-dotenv'
29+
'python-dotenv',
30+
'pybars3'
3031
],
3132
python_requires='>=3.8',
3233
)

src/release.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
from os import path
66
from pathlib import Path
7+
from pybars import Compiler
78

9+
compiler = Compiler()
810

911
def processRelease(repo, payload):
1012
base_path = Path(__file__).parent
@@ -27,13 +29,19 @@ def processRelease(repo, payload):
2729
commands.append('nvm use ' + data['node'])
2830

2931
if 'build' in data['release'].keys():
30-
commands.append(data['release']['build'])
32+
source = data['release']['build']
33+
template = compiler.compile(source)
34+
commands.append(template(payload))
3135

3236
if 'deploy' in data['release'].keys():
33-
commands.append(data['release']['deploy'])
37+
source = data['release']['deploy']
38+
template = compiler.compile(source)
39+
commands.append(template(payload))
3440

3541
if 'cleanup' in data['release'].keys():
36-
commands.append(data['release']['cleanup'])
42+
source = data['release']['cleanup']
43+
template = compiler.compile(source)
44+
commands.append(template(payload))
3745

3846
subprocess.check_call(['git', 'fetch', '--all', '--tags'], cwd=data['path'])
3947
subprocess.check_call(['git', 'checkout', 'tags/' + payload['release']['tag_name']], cwd=data['path'])
@@ -48,10 +56,12 @@ def processRelease(repo, payload):
4856
if line:
4957
print(line.rstrip())
5058
except subprocess.TimeoutExpired:
51-
print('Process was killed by timeout: 300 seconds.')
59+
print('Process was killed by timeout: 300 seconds')
5260
raise
5361
finally:
62+
print('Process complete')
5463
process.kill()
5564
process.communicate()
65+
print('Release complete!')
5666

5767
return

src/test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from pybars import Compiler
2+
3+
compiler = Compiler()
4+
5+
6+
source = r'tar xzf /project/repo/{{release.sha}}.tar.gz'
7+
template = compiler.compile(source)
8+
print(template({
9+
'release': {
10+
'sha': '302f2b072d46b2f48706eb156f162d901be2c088'
11+
}
12+
}))

0 commit comments

Comments
 (0)