Skip to content

Commit 17663b0

Browse files
committed
github: deploy all branches
Make it possible to push any branches for testing.
1 parent 84d1170 commit 17663b0

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

.github/config.py

+22-7
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,43 @@
44
import json
55
import subprocess
66

7+
def git(cmd):
8+
return subprocess.run(cmd, text=True, stdout=subprocess.PIPE).stdout.strip().splitlines()
9+
710
def git_tags():
811
cmd = ['git', 'tag', '--list', '--sort=version:refname']
912

10-
return subprocess.run(cmd, text=True, stdout=subprocess.PIPE).stdout.strip().splitlines()
13+
return git(cmd)
14+
15+
def git_branches():
16+
cmd = ['git', 'branch', '--list', '--format=%(refname:short)']
1117

18+
return git(cmd)
1219

1320
def main():
1421
parser = argparse.ArgumentParser()
22+
parser.add_argument('--tags', action='store_true')
23+
parser.add_argument('--branches', action='store_true')
1524
parser.add_argument('--latest', action='store_true')
1625
args = parser.parse_args()
1726

18-
tags = git_tags()
19-
2027
if args.latest:
21-
print(tags[-1])
28+
print(git_tags()[-1])
2229
return
2330

24-
tags = [ { 'ref': tag, 'name': tag } for tag in tags ]
25-
tags += [ { 'ref': 'main', 'name': 'testing' } ]
31+
refs = []
32+
33+
if args.tags:
34+
refs += git_tags()
35+
36+
if args.branches:
37+
refs += git_branches()
38+
refs = [ ref for ref in refs if '/' not in ref ]
39+
40+
refs = [ { 'ref': ref, 'name': ref } for ref in refs ]
2641

2742
matrix = {
28-
'include': tags,
43+
'include': refs,
2944
}
3045

3146
print(json.dumps(matrix))

.github/workflows/deploy.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
fetch-depth: 0
1515
- id: version-matrix
16-
run: echo "matrix=$(.github/config.py)" | tee $GITHUB_OUTPUT
16+
run: echo "matrix=$(.github/config.py --tags --branches)" | tee $GITHUB_OUTPUT
1717
- id: latest
1818
run: echo "latest=$(.github/config.py --latest)" | tee $GITHUB_OUTPUT
1919

@@ -69,6 +69,9 @@ jobs:
6969
- run: |
7070
mkdir stable
7171
echo "<meta http-equiv=\"refresh\" content=\"0; url=../v0.1.0\" />" > stable/index.html
72+
- run: |
73+
mkdir testing
74+
echo "<meta http-equiv=\"refresh\" content=\"0; url=../main\" />" > testing/index.html
7275
- run: find
7376
- uses: actions/configure-pages@v1
7477
- uses: actions/upload-pages-artifact@v1

0 commit comments

Comments
 (0)