Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update maps-docs repo when main is updated #3199

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Update docs to maps-docs repo

on:
push:
branches:
- main

jobs:
update_docs:
name: Update docs on maps-docs repo
runs-on: ubuntu-latest
defaults:
run:
working-directory: maps
steps:
- name: Install ImageMagick
run: sudo apt-get install -y imagemagick
working-directory: /
- name: test convert
run: convert -version
working-directory: /
- name: Checkout maps repo
uses: actions/checkout@v4
with:
path: maps
- name: Checkout maps-docs repo
uses: actions/checkout@v4
with:
repository: rnmapbox/maps-docs
ssh-key: ${{ secrets.MAPS_DOCS_DEPLOY_KEY }}
path: maps-docs
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: yarn install
- name: Generate component docs into maps-docs repo
run: node scripts/doc-generate.mjs
- name: Generate example docs into maps-docs repo
run: bun scripts/example-docs.ts
- name: Setup deploy key for github deploy
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.MAPS_DOCS_DEPLOY_KEY }}
- name: Add all changed files to git and push to origin main
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Update docs from maps rnmapbox/maps@${GITHUB_SHA::7}"
git push origin main
working-directory: maps-docs
env:
GITHUB_SHA: ${{ github.sha }}

8 changes: 7 additions & 1 deletion scripts/example-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import * as path from 'path';
import * as fs from 'fs';
import { execSync } from 'child_process';
import Os from 'os';

// eslint-disable-next-line import/order
import {
Expand Down Expand Up @@ -63,7 +64,12 @@ examples.forEach(({ groupName, examples, metadata }) => {
const imageName = path.basename(imagePath);
const imageDestPath = path.join(destGroupDir, imageName);
fs.copyFileSync(path.join(docSiteRootPath, imagePath), imageDestPath);
execSync(`sips -Z 640 ${imageDestPath}`);
if (Os.platform() === 'darwin') {
execSync(`sips -Z 640 ${imageDestPath}`);
} else {
execSync(`convert -resize x640 ${imageDestPath} ${imageDestPath}`);
}

return { title: imageName, filename: imageName };
},
);
Expand Down
Loading