sp-dev-fx-webparts/.github/workflows/merge-json.yml

78 lines
2.3 KiB
YAML
Raw Normal View History

2024-03-24 22:48:03 -04:00
name: Merge JSON
2024-03-24 14:31:20 -04:00
on:
2024-03-24 23:13:37 -04:00
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
2024-03-24 21:21:17 -04:00
push:
branches:
2024-03-24 23:13:37 -04:00
# When someone push to `main` branch
2024-03-24 21:21:17 -04:00
- main
2024-03-24 23:13:37 -04:00
paths:
- 'samples/**/assets/sample.json'
2024-03-24 14:31:20 -04:00
jobs:
2024-03-24 22:48:03 -04:00
merge:
2024-03-24 14:31:20 -04:00
runs-on: ubuntu-latest
2024-03-24 22:48:03 -04:00
2024-03-24 14:31:20 -04:00
steps:
2024-03-24 21:21:17 -04:00
- name: Checkout main branch
2024-03-24 22:48:03 -04:00
uses: actions/checkout@v2
2024-03-24 21:21:17 -04:00
with:
ref: main
path: main
2024-03-24 22:48:03 -04:00
2024-03-24 21:21:17 -04:00
- name: Checkout gh-pages branch
2024-03-24 22:48:03 -04:00
uses: actions/checkout@v2
2024-03-24 21:21:17 -04:00
with:
ref: gh-pages
path: gh-pages
2024-03-24 22:48:03 -04:00
2024-03-24 21:21:17 -04:00
- name: Checkout Docs branch
2024-03-24 22:48:03 -04:00
uses: actions/checkout@v2
2024-03-24 21:21:17 -04:00
with:
ref: Docs
path: Docs
2024-03-24 14:31:20 -04:00
- name: Setup Node.js
uses: actions/setup-node@v2
with:
2024-03-24 14:48:51 -04:00
node-version: '20'
2024-03-24 14:31:20 -04:00
- name: Install dependencies
2024-03-24 14:43:49 -04:00
run: npm install lodash
2024-03-24 14:31:20 -04:00
2024-03-24 21:21:17 -04:00
- name: Download Extension samples
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3.raw" \
2024-03-24 22:48:03 -04:00
-o ./main/.metadata/extension-samples.json \
2024-03-24 21:21:17 -04:00
https://raw.githubusercontent.com/pnp/sp-dev-fx-extensions/main/.metadata/samples.json
2024-03-24 21:47:50 -04:00
- name: Join samples
run: |
2024-03-24 22:48:03 -04:00
jq -s '[.[][]]' ./main/samples/**/assets/sample.json ./main/.metadata/extension-samples.json > ./Docs/docs/samples.json
2024-03-24 21:47:50 -04:00
2024-03-24 22:48:03 -04:00
- name: Copy samples.json to gh-pages branch
run: cp ./Docs/docs/samples.json ./gh-pages/samples.json
- name: Commit samples.json to gh-pages branch
run: |
cd gh-pages
git config --local user.email "${{ secrets.USER_EMAIL }}"
git config --local user.name "${{ secrets.USER_NAME }}"
git add samples.json
git commit -m "Update samples.json in gh-pages branch"
git push origin gh-pages
- name: Copy samples.json to Docs branch
run: cp ./Docs/docs/samples.json ./Docs/docs/samples.json
- name: Commit samples.json to Docs branch
run: |
cd Docs
git config --local user.email "${{ secrets.USER_EMAIL }}"
git config --local user.name "${{ secrets.USER_NAME }}"
git add docs/samples.json
git commit -m "Update samples.json in Docs branch"
git push origin Docs