Skip to content

Commit c7a0558

Browse files
authored
Merge pull request #242 from contentauth/ok-nick/update-schemas-workflow
ci: update doc schemas on c2pa-rs release
2 parents 071cf5e + 7a7e2c6 commit c7a0558

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Update schemas to latest
2+
on:
3+
repository_dispatch:
4+
types: [c2pa-rs-release]
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
update-schemas:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
19+
- name: Checkout json-manifest-reference repository
20+
uses: actions/checkout@v5
21+
with:
22+
repository: contentauth/json-manifest-reference
23+
path: ./json-manifest-reference
24+
25+
- name: Checkout c2pa-rs repository
26+
uses: actions/checkout@v5
27+
with:
28+
repository: contentauth/c2pa-rs
29+
path: ./c2pa-rs
30+
fetch-depth: 0
31+
32+
- name: Get latest c2pa-rs version
33+
working-directory: ./c2pa-rs
34+
run: |
35+
latest_tag=$(git tag -l "c2pa-v*" --sort=-v:refname | head -n 1)
36+
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
37+
echo "$latest_tag"
38+
39+
- name: Install Rust toolchain
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Cache Rust dependencies
43+
uses: Swatinem/rust-cache@v2
44+
45+
- name: Build schemas
46+
working-directory: ./c2pa-rs
47+
run: cargo run --bin export_schema
48+
49+
- name: Move new schemas into ./json-manifest-reference/_data
50+
run: |
51+
# We also rename the schemas to have an underscore in the filename instead of a dot to fix
52+
# compatibility issues with Ruby/Jekyll.
53+
for path in ./c2pa-rs/target/schema/*.schema.json; do
54+
name=$(basename "$path")
55+
new=${name/.schema/_schema}
56+
cp "$path" "./json-manifest-reference/_data/$new"
57+
done
58+
59+
- name: Check schemas for diff
60+
id: diffs
61+
working-directory: ./json-manifest-reference
62+
run: |
63+
if [ -n "$(git status --porcelain -- ./_data/)" ]; then
64+
echo "diff=true" >> "$GITHUB_OUTPUT"
65+
echo "true"
66+
else
67+
echo "diff=false" >> "$GITHUB_OUTPUT"
68+
echo "false"
69+
fi
70+
71+
- name: Install Ruby and build and cache dependencies
72+
if: steps.diffs.outputs.diff == 'true'
73+
uses: ruby/setup-ruby@v1
74+
with:
75+
ruby-version: '2.7.4'
76+
bundler-cache: true
77+
working-directory: ./json-manifest-reference
78+
79+
- name: Build Jekyll
80+
if: steps.diffs.outputs.diff == 'true'
81+
working-directory: ./json-manifest-reference
82+
run: bundle exec jekyll build
83+
84+
- name: Move new built schemas into ./docs/manifest/json-ref
85+
if: steps.diffs.outputs.diff == 'true'
86+
# TODO: ideally we don't hardcode these paths, but we need to sort out a fix in the docs
87+
run: |
88+
cp ./json-manifest-reference/_site/manifest-def.html ./docs/manifest/json-ref
89+
cp ./json-manifest-reference/_site/reader.html ./docs/manifest/json-ref
90+
cp ./json-manifest-reference/_site/settings.html ./docs/manifest/json-ref
91+
92+
- name: Send schema PR
93+
if: steps.diffs.outputs.diff == 'true'
94+
uses: peter-evans/create-pull-request@v7
95+
with:
96+
title: 'docs(schema): update schemas to ${{ env.latest_tag }}'
97+
body: 'Updates schemas to ${{ env.latest_tag }}.'
98+
commit-message: 'docs(schema): update schemas to ${{ env.latest_tag }}'
99+
branch: 'schema-${{ env.latest_tag }}'
100+
add-paths: ./docs/manifest/json-ref/*
101+
base: ${{ github.event.repository.default_branch }}

0 commit comments

Comments
 (0)