-
Notifications
You must be signed in to change notification settings - Fork 253
120 lines (98 loc) · 4.38 KB
/
CI_docusaurus_sync.yml
File metadata and controls
120 lines (98 loc) · 4.38 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Core / Sync API reference with Docusaurus
on:
push:
tags:
- "**-v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch: # Activate this workflow manually
inputs:
tag:
description: "Tag with this format: integrations/<INTEGRATION_FOLDER_NAME>-v1.0.0 or integrations/<INTEGRATION_FOLDER_NAME>-v1.0.0.post0. When running this workflow manually, version is irrelevant so you can use any value."
required: true
type: string
default: integrations/<INTEGRATION_FOLDER_NAME>-v1.0.0
env:
TAG: ${{ inputs.tag || github.ref_name }}
jobs:
generate-api-reference:
runs-on: ubuntu-slim
outputs:
integration_name: ${{ steps.pathfinder.outputs.integration_name }}
steps:
- name: Checkout this repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
- name: Install Hatch
run: pip install hatch
- name: Get project folder
id: pathfinder
shell: python
run: |
import os
project_path = os.environ["TAG"].rsplit("-", maxsplit=1)[0]
integration_name = project_path.split("/")[-1]
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
print(f'project_path={project_path}', file=f)
print(f'integration_name={integration_name}', file=f)
- name: Generate API reference
working-directory: ${{ steps.pathfinder.outputs.project_path }}
run: hatch run docs
- name: Upload API reference artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.pathfinder.outputs.integration_name }}
path: ${{ steps.pathfinder.outputs.project_path }}/${{ steps.pathfinder.outputs.integration_name }}.md
if-no-files-found: error
retention-days: 1
overwrite: true
sync-api-reference:
runs-on: ubuntu-slim
needs: generate-api-reference
steps:
- name: Checkout Haystack repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: deepset-ai/haystack
ref: main
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.10"
- name: Download API reference artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ needs.generate-api-reference.outputs.integration_name }}
- name: Sync API reference
shell: python
env:
INTEGRATION_NAME: ${{ needs.generate-api-reference.outputs.integration_name }}
run: |
import os
import shutil
artifact_filename = os.environ['INTEGRATION_NAME']+'.md'
# Copy to main API reference
shutil.copy(artifact_filename, "docs-website/reference/integrations-api/")
# Copy to versioned API reference
for version_dir in os.scandir("docs-website/reference_versioned_docs"):
if version_dir.is_dir():
# example: docs-website/reference_versioned_docs/version-2.17/integrations-api
integrations_api_ref_dir = os.path.join(version_dir.path, "integrations-api")
shutil.copy(artifact_filename, integrations_api_ref_dir)
os.remove(artifact_filename)
- name: Create Pull Request
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
env:
INTEGRATION_NAME: ${{ needs.generate-api-reference.outputs.integration_name }}
with:
token: ${{ secrets.HAYSTACK_BOT_TOKEN }}
commit-message: "Sync Core Integrations API reference (${{ env.INTEGRATION_NAME }}) on Docusaurus"
branch: sync-docusaurus-api-reference-${{ env.INTEGRATION_NAME }}
base: main
title: "docs: sync Core Integrations API reference (${{ env.INTEGRATION_NAME }}) on Docusaurus"
add-paths: |
docs-website
body: |
This PR syncs the Core Integrations API reference (${{ env.INTEGRATION_NAME }}) on Docusaurus. Just approve and merge it.