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

73 lines
2.2 KiB
YAML
Raw Normal View History

2022-02-13 13:29:45 -05:00
name: Merge sample metadata
2022-02-12 15:48:05 -05:00
on:
2023-08-05 17:28:22 -04:00
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
2022-02-12 22:08:39 -05:00
push:
2022-02-12 22:05:46 -05:00
branches:
# When someone push to `main` branch
- main
paths:
- 'samples/**/assets/sample.json'
2022-02-12 15:48:05 -05:00
jobs:
2022-02-12 19:02:52 -05:00
build:
2022-02-12 19:42:39 -05:00
name: 'Merge all sample.json files to samples.json'
2022-02-12 19:02:52 -05:00
runs-on: ubuntu-latest
2022-02-12 15:48:05 -05:00
steps:
2022-02-13 03:08:28 -05:00
- name: Checkout main branch
2024-03-24 13:53:05 -04:00
uses: actions/checkout@v4
2022-02-13 03:08:28 -05:00
with:
2024-03-24 13:51:49 -04:00
node-version: '20'
2022-02-13 03:08:28 -05:00
ref: main
path: main
- name: Checkout gh-pages branch
2024-03-24 13:53:05 -04:00
uses: actions/checkout@v4
2022-02-13 03:08:28 -05:00
with:
2024-03-24 13:51:49 -04:00
node-version: '20'
2022-02-13 03:08:28 -05:00
ref: gh-pages
path: gh-pages
2022-02-13 13:28:08 -05:00
- name: Checkout Docs branch
2024-03-24 13:53:05 -04:00
uses: actions/checkout@v4
2022-02-13 13:28:08 -05:00
with:
2024-03-24 13:51:49 -04:00
node-version: '20'
2022-02-13 13:28:08 -05:00
ref: Docs
path: Docs
2023-08-05 17:28:22 -04:00
- name: Download Extension samples
run: |
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3.raw" \
2023-08-05 17:51:40 -04:00
-o ./main/.metada/extension-samples.json \
2023-08-05 17:31:30 -04:00
https://raw.githubusercontent.com/pnp/sp-dev-fx-extensions/main/.metadata/samples.json
2022-02-13 03:08:28 -05:00
- name: Join samples
run: |
2023-08-05 17:51:40 -04:00
jq -s '[.[][]]' ./main/samples/**/assets/sample.json ./main/.metada/extension-samples.json > ./Docs/docs/samples.json
2022-02-12 20:34:18 -05:00
- name: Validate JSON
2023-08-05 17:57:37 -04:00
continue-on-error: true
2022-02-12 20:33:06 -05:00
uses: docker://orrosenblatt/validate-json-action:latest
env:
INPUT_SCHEMA: ./main/templates/metadata-schema.json
2022-02-13 15:21:34 -05:00
INPUT_JSONS: ./Docs/docs/samples.json
2022-02-13 13:28:08 -05:00
- name: copy file to gh-pages
2022-02-13 03:08:28 -05:00
uses: canastro/copy-file-action@master
with:
2022-02-13 15:21:34 -05:00
source: "./Docs/docs/samples.json"
2022-02-13 03:08:28 -05:00
target: "./gh-pages/samples.json"
- name: Commit samples.json to gh-pages
2023-08-05 17:53:39 -04:00
uses: EndBug/add-and-commit@v9
2022-02-12 20:15:57 -05:00
with:
2022-02-13 03:08:28 -05:00
cwd: ./gh-pages
branch: gh-pages
add: 'samples.json --force'
push: true
token: ${{ secrets.GITHUB_TOKEN }}
2022-02-13 13:28:08 -05:00
- name: Commit samples.json to Docs
2023-08-05 17:53:39 -04:00
uses: EndBug/add-and-commit@v9
2022-02-13 13:28:08 -05:00
with:
cwd: ./Docs
branch: Docs
add: 'docs/samples.json --force'
push: true
token: ${{ secrets.GITHUB_TOKEN }}