|
1 | 1 | name: Automated OpenAPI Spec Update |
2 | 2 |
|
3 | | -# Test update |
4 | | - |
5 | 3 | on: |
6 | | - # 1. Manually trigger the workflow from the GitHub UI |
| 4 | + # Allows manual triggering and selection of branch from the Actions tab |
7 | 5 | workflow_dispatch: |
8 | | - # 2. Trigger the workflow on a schedule (e.g., every day at midnight UTC) |
| 6 | + |
| 7 | + # *** ADDED: This trigger ensures the workflow appears and runs when you push to ANY branch *** |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - '*' |
| 11 | + |
| 12 | + # Runs the workflow on a daily schedule |
9 | 13 | schedule: |
10 | 14 | - cron: '0 0 * * *' |
11 | | - # 3. Optional: Trigger on push to a specific branch (e.g., 'main') |
12 | | - # push: |
13 | | - # branches: |
14 | | - # - main |
15 | 15 |
|
16 | 16 | jobs: |
17 | 17 | generate_and_scrape: |
18 | | - # Use a standard Linux runner |
19 | 18 | runs-on: ubuntu-latest |
20 | 19 |
|
21 | | - # Grant the default GITHUB_TOKEN permissions to write back to the repo |
| 20 | + # Permissions are required for the auto-commit action to push changes back |
22 | 21 | permissions: |
23 | 22 | contents: write |
24 | 23 |
|
25 | 24 | steps: |
26 | 25 | - name: ⬇️ Checkout docs-v2 (This) Repository |
27 | | - # This checks out the repository where the workflow file lives |
28 | 26 | uses: actions/checkout@v4 |
29 | 27 | with: |
30 | 28 | path: docs-v2 |
31 | | - # Fetch a deeper history, required for the auto-commit action |
32 | 29 | fetch-depth: 0 |
33 | 30 |
|
34 | 31 | - name: ⬇️ Checkout api2 Source Repository |
35 | | - # Check out the external API repo into a separate directory |
36 | 32 | uses: actions/checkout@v4 |
37 | 33 | with: |
38 | | - repository: atko-cic/api2 # <<< UPDATE THIS TO YOUR API REPO PATH |
| 34 | + repository: atko-cic/api2 # <<< VERIFY THIS REPO PATH |
39 | 35 | path: api2 |
40 | 36 |
|
41 | | - - name: 🛠️ Setup Node.js (for both repos) |
| 37 | + - name: 🛠️ Setup Node.js |
42 | 38 | uses: actions/setup-node@v4 |
43 | 39 | with: |
44 | 40 | node-version: '20' |
45 | 41 |
|
46 | 42 | - name: 📦 Install dependencies in api2 |
47 | | - # Installs dependencies needed to run the spec generation script |
48 | 43 | run: | |
49 | 44 | cd api2 |
50 | 45 | npm ci |
51 | 46 |
|
52 | 47 | - name: ⚙️ Generate OAPI Spec |
53 | | - # Runs the command to generate the JSON spec file (e.g., api2.json) |
54 | 48 | run: | |
55 | 49 | cd api2 |
56 | 50 | npm run spec:generate -w packages/main-api |
57 | | - # Assuming the generated file is named 'api2.json' in the api2 root after the run |
58 | 51 |
|
59 | 52 | - name: 📝 Copy and Modify OpenAPI Spec for Mintlify |
60 | | - # This block handles file transfer and the necessary tokenUrl replacement |
61 | 53 | run: | |
62 | 54 | # 1. Copy the generated file to the docs location |
63 | 55 | cp api2/api2.json docs-v2/main/docs/api2-3.1-internal.json |
64 | 56 | |
65 | | - # 2. Perform the tokenUrl replacement for OAPI3 compliance (using sed) |
66 | | - # Note: 'sed' is necessary to update the security block as you described |
| 57 | + # 2. Perform the tokenUrl replacement |
67 | 58 | sed -i 's|"tokenUrl": "https://{tenantDomain}/oauth/token"|"tokenUrl": "https://your-tenant-domain.auth0.com/oauth/token"|g' docs-v2/main/docs/api2-3.1-internal.json |
68 | 59 | |
69 | 60 | - name: 🧹 Scrape OpenAPI to MDX files |
70 | | - # Run the Mintlify scraping command from the docs-v2 root |
71 | | - # This generates all the Markdown files in the 'api-reference' folder |
72 | 61 | run: | |
73 | 62 | cd docs-v2/main |
74 | 63 | npx @mintlify/scraping@latest openapi-file docs/api2-3.1-internal.json -o api-reference |
75 | 64 |
|
76 | 65 | - name: 💾 Commit and Push generated files |
77 | | - # This action automatically stages, commits, and pushes any file changes |
78 | | - # (the new/updated MDX files) back to the docs-v2 repo. |
79 | 66 | uses: stefanzweifel/git-auto-commit-action@v5 |
80 | 67 | with: |
81 | | - # Crucial: Specify the repository path where changes happened |
82 | 68 | repository: docs-v2 |
83 | 69 | commit_message: "Automated: Update API reference from latest api2 spec" |
84 | 70 | commit_user_name: 'GitHub Actions Bot' |
|
0 commit comments