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

78 lines
2.3 KiB
YAML

name: Merge JSON
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
push:
branches:
# When someone push to `main` branch
- main
paths:
- 'samples/**/assets/sample.json'
jobs:
merge:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v2
with:
ref: main
path: main
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages
- name: Checkout Docs branch
uses: actions/checkout@v2
with:
ref: Docs
path: Docs
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm install lodash
- name: Download Extension samples
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3.raw" \
-o ./main/.metadata/extension-samples.json \
https://raw.githubusercontent.com/pnp/sp-dev-fx-extensions/main/.metadata/samples.json
- name: Join samples
run: |
jq -s '[.[][]]' ./main/samples/**/assets/sample.json ./main/.metadata/extension-samples.json > ./Docs/docs/samples.json
- 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