Ray Chen commited on
Commit
22ed5bf
·
1 Parent(s): 2e621ff

change: only deploy when main branch pushed

Browse files
.github/tools/config.py CHANGED
@@ -4,7 +4,7 @@ from model import Config
4
 
5
  UserName = Literal["default"]
6
 
7
- SPACE_CONFIG: Dict[UserName, Config] = {
8
  "default": {
9
  "space_name": "example",
10
  "space_owner": "jy-raychen",
 
4
 
5
  UserName = Literal["default"]
6
 
7
+ PRODUCTION_SPACE_CONFIG: Dict[UserName, Config] = {
8
  "default": {
9
  "space_name": "example",
10
  "space_owner": "jy-raychen",
.github/tools/deploy_to_space.py CHANGED
@@ -2,7 +2,7 @@ import argparse
2
  import subprocess
3
  import sys
4
 
5
- from config import SPACE_CONFIG
6
  from model import Space
7
 
8
 
@@ -34,7 +34,8 @@ if __name__ == "__main__":
34
  parser.add_argument("--user_token", required=True)
35
  args = parser.parse_args()
36
 
37
- space = Space(SPACE_CONFIG["default"])
 
38
 
39
  push_result = force_push_to_remote(
40
  space, args.username, args.user_token, args.branch_name
 
2
  import subprocess
3
  import sys
4
 
5
+ from config import PRODUCTION_SPACE_CONFIG
6
  from model import Space
7
 
8
 
 
34
  parser.add_argument("--user_token", required=True)
35
  args = parser.parse_args()
36
 
37
+ # TODO: Use different space config when deploy to dev environment.
38
+ space = Space(PRODUCTION_SPACE_CONFIG["default"])
39
 
40
  push_result = force_push_to_remote(
41
  space, args.username, args.user_token, args.branch_name
.github/tools/generate_readme.py CHANGED
@@ -1,6 +1,6 @@
1
  import sys
2
 
3
- from config import SPACE_CONFIG
4
  from model import ReadMe, Space
5
 
6
  DEFAULT_USER = "jy-raychen"
@@ -22,7 +22,7 @@ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-
22
 
23
 
24
  if __name__ == "__main__":
25
- space = Space(SPACE_CONFIG["default"])
26
 
27
  readme = readme_template(space.readme)
28
  print(readme)
 
1
  import sys
2
 
3
+ from config import PRODUCTION_SPACE_CONFIG
4
  from model import ReadMe, Space
5
 
6
  DEFAULT_USER = "jy-raychen"
 
22
 
23
 
24
  if __name__ == "__main__":
25
+ space = Space(PRODUCTION_SPACE_CONFIG["default"])
26
 
27
  readme = readme_template(space.readme)
28
  print(readme)
.github/workflows/{deploy-to-space.yaml → deploy-to-production.yaml} RENAMED
@@ -1,10 +1,10 @@
1
- name: Deploy Space
2
- run-name: Deploy to space
3
 
4
  on:
5
  push:
6
  branches:
7
- - '**'
8
 
9
  concurrency:
10
  group: ${{ github.workflow }}-${{ github.ref_name }}
 
1
+ name: Deploy Production
2
+ run-name: Deploy to production space
3
 
4
  on:
5
  push:
6
  branches:
7
+ - 'main'
8
 
9
  concurrency:
10
  group: ${{ github.workflow }}-${{ github.ref_name }}