-
Notifications
You must be signed in to change notification settings - Fork 38
67 lines (57 loc) · 2.12 KB
/
get-cloud-api-spec.yml
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
name: Fetch and Save Cloud API Spec
on:
workflow_dispatch: # Allows manual trigger of the workflow
repository_dispatch: # Allows other repositories to trigger this workflow
types: [trigger-cloud-api-docs]
jobs:
fetch-and-save-cloud-api-spec:
runs-on: ubuntu-latest
steps:
- name: Check out repository (main branch)
uses: actions/checkout@v3
with:
ref: 'main'
path: redpanda-docs
token: ${{ secrets.VBOT_GITHUB_API_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: |
cd ./redpanda-docs/scripts/get-api-specs
npm install
- name: Run the script and save the output
run: node ./redpanda-docs/scripts/get-api-specs/get-cloud-api-spec.js > ./redpanda-docs/cloud-api.yaml
env:
VBOT_GITHUB_API_TOKEN: ${{ secrets.ACTIONS_BOT_TOKEN }}
- name: Check out the api branch
run: |
cd ./redpanda-docs
git fetch --all
git checkout api
# Copy the generated file to the api branch
- name: Copy the file to the api branch
run: |
mv ./redpanda-docs/cloud-api.yaml ./redpanda-docs/modules/ROOT/attachments/cloud-api.yaml
- name: Check if changes were made
id: check_changes
run: |
cd ./redpanda-docs
git status --porcelain
if [ $(git status --porcelain | grep -v 'node_modules\|scripts/' | wc -l) -gt 0 ]; then
echo "has_changes=true" >> $GITHUB_ENV
else
echo "has_changes=false" >> $GITHUB_ENV
fi
- name: Commit changes to the api branch
if: env.has_changes == 'true'
run: |
cd ./redpanda-docs
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add modules/ROOT/attachments/cloud-api.yaml
git commit -m "auto-docs: Update Cloud API spec"
git push origin api
env:
ACCESS_TOKEN: ${{ secrets.VBOT_GITHUB_API_TOKEN }}