-
Notifications
You must be signed in to change notification settings - Fork 3
114 lines (98 loc) · 3.76 KB
/
Copy pathupgrade-docs.yml
File metadata and controls
114 lines (98 loc) · 3.76 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
name: Upgrade Documentation Dependencies
on:
schedule:
# Run every Monday at 9:00 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch: # Allow manual trigger
push:
branches: [ main, 'feature/**' ]
paths:
- 'docs/**'
- '.github/workflows/upgrade-docs.yml'
pull_request:
branches: [ main, 'feature/**' ]
paths:
- 'docs/**'
- '.github/workflows/upgrade-docs.yml'
permissions:
contents: write
pull-requests: write
jobs:
upgrade:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Locate docs workspace
id: docs_workspace
run: |
if [ -f docs/mint.json ]; then
echo "workdir=docs" >> "$GITHUB_OUTPUT"
else
echo "workdir=." >> "$GITHUB_OUTPUT"
fi
- name: Check for Mintlify updates
id: check_updates
working-directory: ${{ steps.docs_workspace.outputs.workdir }}
run: |
# Read currently pinned local Mintlify version, if any.
if [ -f package.json ]; then
CURRENT_VERSION=$(node -e "const fs=require('fs');const p='package.json';const pkg=JSON.parse(fs.readFileSync(p,'utf8'));const v=(pkg.devDependencies&&pkg.devDependencies.mintlify)||(pkg.dependencies&&pkg.dependencies.mintlify)||'';process.stdout.write(v);")
if [ -z "$CURRENT_VERSION" ]; then
CURRENT_VERSION="not installed"
fi
else
CURRENT_VERSION="not installed"
fi
# Get latest Mintlify version from npm registry.
LATEST_VERSION=$(npm view mintlify version)
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "latest_version=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "updates_available=true" >> "$GITHUB_OUTPUT"
else
echo "updates_available=false" >> "$GITHUB_OUTPUT"
fi
- name: Initialize package.json if not exists
if: steps.check_updates.outputs.updates_available == 'true'
working-directory: ${{ steps.docs_workspace.outputs.workdir }}
run: |
if [ ! -f package.json ]; then
npm init -y
npm pkg set scripts.dev="mintlify dev"
npm pkg set scripts.install="mintlify install"
fi
- name: Update Mintlify CLI
if: steps.check_updates.outputs.updates_available == 'true'
working-directory: ${{ steps.docs_workspace.outputs.workdir }}
run: |
npm install -D mintlify@latest
- name: Create Pull Request
if: steps.check_updates.outputs.updates_available == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: upgrade Mintlify CLI to ${{ steps.check_updates.outputs.latest_version }}'
title: 'chore: upgrade documentation dependencies'
body: |
## Documentation Dependencies Update
This PR automatically upgrades the documentation dependencies.
### Changes
- Mintlify CLI: `${{ steps.check_updates.outputs.current_version }}` -> `${{ steps.check_updates.outputs.latest_version }}`
### Testing
Please verify the documentation builds correctly:
```bash
npm run dev
```
---
*This PR was automatically created by the upgrade-docs workflow*
branch: chore/upgrade-docs-dependencies
delete-branch: true
labels: |
dependencies
documentation
automated