Skip to content

Commit 48f571a

Browse files
authored
Merge pull request #5 from redpanda-data/fix-action
Fix GitHub Action to pick up overlay paths
2 parents 5f40741 + 2cae369 commit 48f571a

File tree

6 files changed

+6417
-35
lines changed

6 files changed

+6417
-35
lines changed

.github/workflows/bump.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -107,29 +107,29 @@ jobs:
107107
run: |
108108
OVERLAYS=""
109109
110-
# Function to add overlay path with comma if needed
111-
add_overlay() {
112-
local overlay_path="$1"
113-
if [ -f "$overlay_path" ]; then
114-
if [ -n "$OVERLAYS" ]; then
115-
OVERLAYS="$OVERLAYS,$overlay_path"
116-
else
117-
OVERLAYS="$overlay_path"
118-
fi
119-
fi
120-
}
121-
122-
# Check for doc-specific overlays (list each overlay file individually)
110+
# Check for doc-specific overlays
123111
if [ -d "${{ matrix.doc_id }}/overlays" ]; then
124-
find "${{ matrix.doc_id }}/overlays" -name "*.yaml" -type f | sort | while read overlay_file; do
125-
add_overlay "$overlay_file"
112+
for overlay_file in "${{ matrix.doc_id }}/overlays"/*.yaml; do
113+
if [ -f "$overlay_file" ]; then
114+
if [ -n "$OVERLAYS" ]; then
115+
OVERLAYS="$OVERLAYS,$overlay_file"
116+
else
117+
OVERLAYS="$overlay_file"
118+
fi
119+
fi
126120
done
127121
fi
128122
129123
# Check for shared overlays - only apply to cloud APIs
130124
if [[ "${{ matrix.doc_id }}" == "cloud-"* ]] && [ -d "shared/overlays" ]; then
131-
find "shared/overlays" -name "*.yaml" -type f | sort | while read overlay_file; do
132-
add_overlay "$overlay_file"
125+
for overlay_file in shared/overlays/*.yaml; do
126+
if [ -f "$overlay_file" ]; then
127+
if [ -n "$OVERLAYS" ]; then
128+
OVERLAYS="$OVERLAYS,$overlay_file"
129+
else
130+
OVERLAYS="$overlay_file"
131+
fi
132+
fi
133133
done
134134
fi
135135
@@ -178,29 +178,29 @@ jobs:
178178
run: |
179179
OVERLAYS=""
180180
181-
# Function to add overlay path with comma if needed
182-
add_overlay() {
183-
local overlay_path="$1"
184-
if [ -f "$overlay_path" ]; then
185-
if [ -n "$OVERLAYS" ]; then
186-
OVERLAYS="$OVERLAYS,$overlay_path"
187-
else
188-
OVERLAYS="$overlay_path"
189-
fi
190-
fi
191-
}
192-
193-
# Check for doc-specific overlays (list each overlay file individually)
181+
# Check for doc-specific overlays
194182
if [ -d "${{ matrix.doc_id }}/overlays" ]; then
195-
find "${{ matrix.doc_id }}/overlays" -name "*.yaml" -type f | sort | while read overlay_file; do
196-
add_overlay "$overlay_file"
183+
for overlay_file in "${{ matrix.doc_id }}/overlays"/*.yaml; do
184+
if [ -f "$overlay_file" ]; then
185+
if [ -n "$OVERLAYS" ]; then
186+
OVERLAYS="$OVERLAYS,$overlay_file"
187+
else
188+
OVERLAYS="$overlay_file"
189+
fi
190+
fi
197191
done
198192
fi
199193
200194
# Check for shared overlays - only apply to cloud APIs
201195
if [[ "${{ matrix.doc_id }}" == "cloud-"* ]] && [ -d "shared/overlays" ]; then
202-
find "shared/overlays" -name "*.yaml" -type f | sort | while read overlay_file; do
203-
add_overlay "$overlay_file"
196+
for overlay_file in shared/overlays/*.yaml; do
197+
if [ -f "$overlay_file" ]; then
198+
if [ -n "$OVERLAYS" ]; then
199+
OVERLAYS="$OVERLAYS,$overlay_file"
200+
else
201+
OVERLAYS="$overlay_file"
202+
fi
203+
fi
204204
done
205205
fi
206206
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Fetch and Save Cloud API Spec
2+
3+
on:
4+
workflow_dispatch: # Allows manual trigger of the workflow
5+
repository_dispatch: # Allows other repositories to trigger this workflow
6+
types: [trigger-cloud-api-docs]
7+
8+
jobs:
9+
fetch-and-save-cloud-api-spec:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
13+
contents: read
14+
steps:
15+
- uses: aws-actions/configure-aws-credentials@v4
16+
with:
17+
aws-region: ${{ vars.RP_AWS_CRED_REGION }}
18+
role-to-assume: arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }}
19+
- uses: aws-actions/aws-secretsmanager-get-secrets@v2
20+
with:
21+
secret-ids: |
22+
,sdlc/prod/github/actions_bot_token
23+
parse-json-secrets: true
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '18'
29+
30+
- name: Check out repository
31+
uses: actions/checkout@v4
32+
with:
33+
ref: 'main'
34+
path: redpanda-docs
35+
token: ${{ env.ACTIONS_BOT_TOKEN }}
36+
37+
- name: Get commit SHA and build URL
38+
id: commit-info
39+
run: |
40+
COMMIT_SHA="${{ github.event.client_payload.commit_sha }}"
41+
COMMIT_URL="https://github.com/redpanda-data/cloudv2/commit/${COMMIT_SHA}"
42+
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
43+
echo "COMMIT_URL=${COMMIT_URL}" >> $GITHUB_ENV
44+
45+
- name: Install dependencies
46+
run: |
47+
npm install
48+
49+
- name: Run the script and save the output
50+
run: |
51+
npx doc-tools fetch -o redpanda-data -r cloudv2 -p proto/gen/openapi/openapi.controlplane.prod.yaml -d ../../modules/ROOT/attachments cloud-controlplane-api.yaml
52+
npx doc-tools fetch -o redpanda-data -r cloudv2 -p proto/gen/openapi/openapi.dataplane.prod.yaml -d ../../modules/ROOT/attachments cloud-dataplane-api.yaml
53+
env:
54+
VBOT_GITHUB_API_TOKEN: ${{ env.ACTIONS_BOT_TOKEN }}
55+
- name: Create pull request
56+
uses: peter-evans/create-pull-request@v6
57+
with:
58+
commit-message: "auto-docs: Update Cloud API spec"
59+
token: ${{ env.ACTIONS_BOT_TOKEN }}
60+
path: redpanda-docs
61+
branch: update-branch-api
62+
title: "auto-docs: Update Cloud API spec"
63+
body: |
64+
This PR updates the OpenAPI spec file for the Cloud API.
65+
Triggered by commit: [${{ env.COMMIT_SHA }}](${{ env.COMMIT_URL }})
66+
labels: auto-docs
67+
reviewers: JakeSCahill, kbatuigas

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

cloud-controlplane/cloud-controlplane.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
components:
22
schemas:
33
AWS.Role:
4-
description: Role identifies AWS role.
4+
description: Role (test) identifies AWS role.
55
properties:
66
arn:
77
description: AWS role ARN.

0 commit comments

Comments
 (0)