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

73 lines
2.2 KiB
YAML

name: Merge sample metadata
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
push:
branches:
# When someone push to `main` branch
- main
paths:
- 'samples/**/assets/sample.json'
jobs:
build:
name: 'Merge all sample.json files to samples.json'
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
node-version: '20'
ref: main
path: main
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
node-version: '20'
ref: gh-pages
path: gh-pages
- name: Checkout Docs branch
uses: actions/checkout@v4
with:
node-version: '20'
ref: Docs
path: Docs
- name: Download Extension samples
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3.raw" \
-o ./main/.metada/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/.metada/extension-samples.json > ./Docs/docs/samples.json
- name: Validate JSON
continue-on-error: true
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: ./main/templates/metadata-schema.json
INPUT_JSONS: ./Docs/docs/samples.json
- name: copy file to gh-pages
uses: canastro/copy-file-action@master
with:
source: "./Docs/docs/samples.json"
target: "./gh-pages/samples.json"
- name: Commit samples.json to gh-pages
uses: EndBug/add-and-commit@v9
with:
cwd: ./gh-pages
branch: gh-pages
add: 'samples.json --force'
push: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Commit samples.json to Docs
uses: EndBug/add-and-commit@v9
with:
cwd: ./Docs
branch: Docs
add: 'docs/samples.json --force'
push: true
token: ${{ secrets.GITHUB_TOKEN }}