Skip to content

Commit 305958a

Browse files
committed
untested
1 parent e0d23b7 commit 305958a

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Generate SEC API Historical Python SDK
2+
3+
on:
4+
push:
5+
branches:
6+
- master # Adjust to your default branch (e.g., main) if different
7+
paths:
8+
- 'finfeedapi/sec-api/spec/sec-api-historical.yaml'
9+
pull_request:
10+
branches:
11+
- master # Adjust to your default branch (e.g., main) if different
12+
paths:
13+
- 'finfeedapi/sec-api/spec/sec-api-historical.yaml'
14+
15+
jobs:
16+
build-and-commit-sdk:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
with:
22+
# This token is needed to push changes back to the repository.
23+
# Create a PAT with 'repo' scope and add it as a secret
24+
# in your repository settings (e.g., Settings > Secrets > Actions).
25+
# Replace 'PAT_TOKEN' with the name of your secret.
26+
token: ${{ secrets.PAT_TOKEN }}
27+
28+
- name: Install OpenAPI Generator CLI
29+
run: sudo npm install -g @openapitools/openapi-generator-cli@latest
30+
31+
- name: Generate Python SDK
32+
run: |
33+
echo "Generating Python SDK for finfeedapi/sec-api/spec/sec-api-historical.yaml"
34+
# Create the output directory if it doesn't exist
35+
mkdir -p finfeedapi/sec-api/sdk
36+
openapi-generator-cli generate \
37+
-i finfeedapi/sec-api/spec/sec-api-historical.yaml \
38+
-g python \
39+
-o finfeedapi/sec-api/sdk/ \
40+
-v
41+
echo "SDK generation complete."
42+
43+
- name: Commit and Push SDK
44+
# Only run this step for push events to the specified branch
45+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') # Adjust branch names as needed
46+
run: |
47+
git config --global user.name 'GitHub Actions Bot'
48+
git config --global user.email '[email protected]'
49+
50+
# Navigate to repository root
51+
cd "${{ github.workspace }}"
52+
53+
echo "Adding files from finfeedapi/sec-api/sdk/"
54+
# Add all changes within the SDK directory (new, modified, deleted)
55+
git add finfeedapi/sec-api/sdk/
56+
57+
# Check if there are actual changes to commit
58+
if git diff --staged --quiet; then
59+
echo "No changes to commit in SDK."
60+
else
61+
echo "Changes detected, committing..."
62+
git commit -m "Auto-generate Python SDK for SEC API Historical [skip ci]"
63+
64+
# Configure pull strategy (merge by default if not rebase)
65+
# The example you provided used 'git config pull.rebase false' implicitly by not setting rebase.
66+
# This ensures a merge commit if the remote has diverged.
67+
git config pull.rebase false
68+
69+
CURRENT_BRANCH=$(echo "${{ github.ref }}" | sed 's!refs/heads/!!')
70+
echo "Pulling latest changes from origin/${CURRENT_BRANCH}..."
71+
git pull origin ${CURRENT_BRANCH}
72+
73+
echo "Pushing changes to origin/${CURRENT_BRANCH}..."
74+
git push origin ${CURRENT_BRANCH}
75+
echo "Push complete."
76+
fi

0 commit comments

Comments
 (0)