Update Docs Data #68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Check for changes | |
id: check_changes | |
run: | | |
git add data/*.md | |
if git diff --staged --quiet; then | |
echo "No changes detected in docs data files" | |
echo "changes_detected=false" >> $GITHUB_OUTPUT | |
else | |
echo "Changes detected in docs data files" | |
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 |