Skip to content

Commit a4f3064

Browse files
authored
ci: automatically update schemas on release
1 parent 6ba8dfd commit a4f3064

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 c2pa-rs repository
20+
uses: actions/checkout@v5
21+
with:
22+
repository: contentauth/c2pa-rs
23+
path: ./c2pa-rs
24+
fetch-depth: 0
25+
26+
- name: Get latest c2pa-rs version
27+
working-directory: ./c2pa-rs
28+
run: |
29+
latest_tag=$(git tag -l "c2pa-v*" --sort=-v:refname | head -n 1)
30+
echo "latest_tag=$latest_tag" >> $GITHUB_ENV
31+
echo "$latest_tag"
32+
33+
- name: Install Rust toolchain
34+
uses: dtolnay/rust-toolchain@stable
35+
36+
- name: Build schemas
37+
working-directory: ./c2pa-rs
38+
run: cargo run --bin export_schema
39+
40+
- name: Move new schemas into ./_data
41+
run: cp ./c2pa-rs/target/schema/* ./_data/
42+
43+
- name: Check schemas for diff
44+
id: diffs
45+
run: |
46+
if [ -n "$(git status --porcelain -- _data)" ]; then
47+
echo "diff=true" >> "$GITHUB_OUTPUT"
48+
echo "true"
49+
else
50+
echo "diff=false" >> "$GITHUB_OUTPUT"
51+
echo "false"
52+
fi
53+
54+
- name: Send schema PR
55+
if: steps.diffs.outputs.diff == 'true'
56+
uses: peter-evans/create-pull-request@v7
57+
with:
58+
title: "docs(schema): update schemas to ${{ env.latest_tag }}"
59+
body: "Updates schemas to ${{ env.latest_tag }}."
60+
commit-message: "docs(schema): update schemas to ${{ env.latest_tag }}"
61+
branch: "schema-${{ env.latest_tag }}"
62+
add-paths: ./_data/*
63+
base: ${{ github.event.repository.default_branch }}

0 commit comments

Comments
 (0)