-
Notifications
You must be signed in to change notification settings - Fork 107
149 lines (127 loc) · 5.1 KB
/
Copy pathupdate-docs-data.yaml
File metadata and controls
149 lines (127 loc) · 5.1 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Update Docs Data
on:
workflow_dispatch: # Allow manual triggering via GitHub UI
jobs:
update-docs-data:
runs-on: ubuntu-latest
steps:
- name: Checkout docs repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 8
run_install: false
- name: Get current date and time
id: datetime
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "datetime=$(date +'%Y-%m-%d-%H%M')" >> $GITHUB_OUTPUT
- name: Clone docs-data-updater repository
uses: actions/checkout@v4
with:
repository: pimlicolabs/docs-data-updater
token: ${{ secrets.GH_PAT }}
path: docs-data-updater
- name: Configure npm for private packages
working-directory: docs-data-updater
run: |
echo "@pimlicolabs:registry=https://npm.pkg.github.com/" > .npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc
- name: Install dependencies in docs-data-updater
working-directory: docs-data-updater
run: pnpm install
- name: Build docs-data-updater
working-directory: docs-data-updater
run: pnpm build
- name: Create .env file with database credentials
working-directory: docs-data-updater
run: |
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" > .env
- name: Install ORAS CLI
run: |
curl -LO "https://github.com/oras-project/oras/releases/download/v1.1.0/oras_1.1.0_linux_amd64.tar.gz"
mkdir -p oras-install/
tar -zxf oras_*.tar.gz -C oras-install/
sudo mv oras-install/oras /usr/local/bin/
rm -rf oras_* oras-install/
- name: Pull Pimlico configs
working-directory: docs-data-updater
run: |
# Login to GitHub Container Registry
echo "${{ secrets.GH_PAT }}" | oras login ghcr.io --username ${{ github.actor }} --password-stdin
# Pull the configs
mkdir -p configs && cd configs && rm -f * && oras pull ghcr.io/pimlicolabs/configs:latest
- name: Generate docs data
working-directory: docs-data-updater
run: |
# Run the data generation script
pnpm start
- name: Copy generated markdown files to docs data directory
run: |
# Copy the three generated markdown files from docs-data-updater/data/ to data/
if [ -d "docs-data-updater/data" ]; then
# Copy the specific generated files
for file in chain-details.md supported-chains.md supported-tokens.md; do
if [ -f "docs-data-updater/data/$file" ]; then
cp -f "docs-data-updater/data/$file" "data/$file"
echo "Copied $file"
else
echo "Warning: $file not found in docs-data-updater/data/"
fi
done
else
echo "Error: docs-data-updater/data/ directory not found"
exit 1
fi
- name: Render data into pages
run: pnpm dlx tsx scripts/render-data.ts
- name: Check for changes
id: check_changes
run: |
git add docs/pages
if git diff --staged --quiet; then
echo "No changes detected in rendered pages"
echo "changes_detected=false" >> $GITHUB_OUTPUT
else
echo "Changes detected in rendered pages"
echo "changes_detected=true" >> $GITHUB_OUTPUT
fi
- name: Remove docs-data-updater directory
run: rm -rf docs-data-updater
- name: Get current branch
id: get_branch
run: |
# Default to main if run from workflow_dispatch without a specific branch context
CURRENT_BRANCH=${GITHUB_REF#refs/heads/}
if [ "$CURRENT_BRANCH" = "$GITHUB_REF" ]; then
CURRENT_BRANCH="main"
fi
echo "branch=$CURRENT_BRANCH" >> $GITHUB_OUTPUT
echo "Current branch: $CURRENT_BRANCH"
- name: Create Pull Request
if: steps.check_changes.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update docs data [automated]"
title: "Update docs data - ${{ steps.datetime.outputs.datetime }}"
body: |
This PR updates the docs data from the Pimlico database:
- Chain details
- Supported chains
- Supported tokens
- Updated on: ${{ steps.datetime.outputs.date }}
- Automated update via GitHub Actions
branch: update-docs-data-${{ steps.datetime.outputs.datetime }}
base: ${{ steps.get_branch.outputs.branch }}
delete-branch: true
labels: |
automated
data-update