-
Notifications
You must be signed in to change notification settings - Fork 120
100 lines (86 loc) · 3.54 KB
/
dc_sync.yml
File metadata and controls
100 lines (86 loc) · 3.54 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Sync tutorial with dC workspace
on:
push:
branches:
- main
paths:
- "tutorials/[0-9]*.ipynb"
jobs:
get-tutorials:
runs-on: ubuntu-latest
outputs:
modified-matrix: ${{ steps.create_matrix.outputs.modified-matrix }}
deleted-matrix: ${{ steps.create_matrix.outputs.deleted-matrix }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
fetch-depth: 0
- name: Get changed files
id: files
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
with:
json: true
files: |
./tutorials/[0-9]*.ipynb
- name: Create matrixes
id: create_matrix
run: |
echo "modified-matrix=${{ steps.files.outputs.all_changed_files }}" >> "$GITHUB_OUTPUT"
echo "deleted-matrix=${{ steps.files.outputs.deleted_files }}" >> "$GITHUB_OUTPUT"
modified:
needs: get-tutorials
if: ${{ needs.get-tutorials.outputs.modified-matrix != '[]' && needs.get-tutorials.outputs.modified-matrix != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
file: ${{ fromJSON(needs.get-tutorials.outputs.modified-matrix) }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.11"
- name: Install requirements
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Generate file to upload
id: file-generator
run: |
FILE="$(basename ${{ matrix.file }} .ipynb).txt"
METADATA_FILE="$(basename ${{ matrix.file }} .ipynb).yml"
echo "file=text/$FILE" >> "$GITHUB_OUTPUT"
echo "metadata_file=text/$METADATA_FILE" >> "$GITHUB_OUTPUT"
python scripts/generate_txt.py --metadata --notebooks ${{ matrix.file }}
- name: Upload tutorial to deepset Cloud
uses: silvanocerza/deepset-cloud-file-uploader@b2a34976a31f894154a529b7f4b4cc00edb593a4 # v1.1.2
with:
api-key: ${{ secrets.DEEPSET_CLOUD_API_KEY }}
workspace-name: ${{ secrets.DEEPSET_CLOUD_WORKSPACE }}
file: ${{ steps.file-generator.outputs.file }}
write-mode: OVERWRITE
meta-file: ${{ steps.file-generator.outputs.metadata_file }}
deleted:
needs: get-tutorials
if: ${{ needs.get-tutorials.outputs.deleted-matrix != '[]' && needs.get-tutorials.outputs.deleted-matrix != '' }}
runs-on: ubuntu-latest
strategy:
matrix:
file: ${{ fromJSON(needs.get-tutorials.outputs.deleted-matrix) }}
steps:
# This step is really important as when we remove a tutorial
# notebook we also want to remove the relative file from
# deepset Cloud, but since the remote file will have a .txt
# extension we must first generate the full file name with this step.
- name: Get file with correct extension
id: extension-changer
run: |
FILE="$(basename ${{ matrix.file }} .ipynb).txt"
echo "file=$FILE" >> "$GITHUB_OUTPUT"
- name: Delete file from deepset Cloud
uses: silvanocerza/deepset-cloud-file-deleter@16afef2222bc877b42cf346cce043133debe7c3f # v1.0.0
with:
api-key: ${{ secrets.DEEPSET_CLOUD_API_KEY }}
workspace-name: ${{ secrets.DEEPSET_CLOUD_WORKSPACE }}
file: ${{ steps.extension-changer.outputs.file}}