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

54 lines
1.5 KiB
YAML
Raw Normal View History

2022-02-12 15:48:05 -05:00
name: Merge Sample JSON
on:
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
2022-02-12 19:42:39 -05:00
uses: actions/checkout@v2
2022-02-13 03:08:28 -05:00
with:
ref: main
path: main
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: gh-pages
path: gh-pages
- name: Join samples
run: |
jq -s '[.[][]]' ./main/samples/**/assets/sample.json > ./main/samples.json
2022-02-12 20:34:18 -05:00
- name: Validate JSON
2022-02-12 20:33:06 -05:00
uses: docker://orrosenblatt/validate-json-action:latest
env:
2022-02-13 03:08:28 -05:00
INPUT_SCHEMA: ./main/metadata-schema.json
INPUT_JSONS: ./main/samples.json
- name: copy file
uses: canastro/copy-file-action@master
with:
source: "./main/samples.json"
target: "./gh-pages/samples.json"
- name: Commit updated samples.json
2022-02-12 19:42:39 -05:00
uses: EndBug/add-and-commit@v6
2022-02-12 19:02:52 -05:00
with:
2022-02-12 19:11:58 -05:00
message: 'Updated samples.json'
add: 'samples.json --force'
2022-02-13 03:08:28 -05:00
cwd: './main'
2022-02-12 19:42:39 -05:00
token: ${{ secrets.TOKEN }}
2022-02-13 03:08:28 -05:00
- name: Commit samples.json to gh-pages
uses: EndBug/add-and-commit@v6
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 }}