-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (68 loc) · 2.03 KB
/
deploy-notebooks.yml
File metadata and controls
75 lines (68 loc) · 2.03 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
on:
workflow_call:
inputs:
target-repository:
type: string
required: true
exclude:
type: string
default: '[]'
required: false
secrets:
target_repo_private_key:
required: false
jobs:
deploy:
name: "Deploy"
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
path: src
- name: Checkout target repository
uses: actions/checkout@v4
with:
repository: ${{ inputs.target-repository }}
path: dst
fetch-depth: 1
ssh-key: ${{ secrets.target_repo_private_key }}
- name: Clean up target directory
shell: python
run: |
import os, pathlib, shutil
for filename in os.listdir('dst'):
if filename != '.git':
filepath = 'dst/' + filename
if os.path.isfile(filepath):
os.remove(filepath)
else:
shutil.rmtree('dst/' + filename)
- name: Compose rsync arguments
id: rsync_args
shell: python
run: |
import json, os
path_list = json.loads(os.environ['exclude'])
args = ' '.join(f'--exclude "{path}"' for path in path_list)
with open(os.environ['GITHUB_OUTPUT'], 'a') as outputs:
print('value=' + args, file=outputs)
env:
exclude: ${{ inputs.exclude }}
- name: Populate target directory
shell: bash
run: |
rsync -av "src/" "dst" \
--exclude ".git" \
--exclude ".github/dependabot.yml" \
--exclude "_solutions" \
--exclude "_deploy" \
${{ steps.rsync_args.outputs.value }}
cp -Rf src/_deploy/* "dst/"
- name: Squash and deploy
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_options: '--amend --no-edit'
push_options: '--force'
skip_fetch: true
repository: dst