|
| 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: cp ./c2pa-rs/target/schema/* ./json-manifest-reference/_data/ |
| 51 | + |
| 52 | + - name: Check schemas for diff |
| 53 | + id: diffs |
| 54 | + working-directory: ./json-manifest-reference |
| 55 | + run: | |
| 56 | + if [ -n "$(git status --porcelain -- ./_data/)" ]; then |
| 57 | + echo "diff=true" >> "$GITHUB_OUTPUT" |
| 58 | + echo "true" |
| 59 | + else |
| 60 | + echo "diff=false" >> "$GITHUB_OUTPUT" |
| 61 | + echo "false" |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Install Ruby and build and cache dependencies |
| 65 | + if: steps.diffs.outputs.diff == 'true' |
| 66 | + uses: ruby/setup-ruby@v1 |
| 67 | + with: |
| 68 | + ruby-version: '2.7.4' |
| 69 | + bundler-cache: true |
| 70 | + working-directory: ./json-manifest-reference |
| 71 | + |
| 72 | + - name: Build Jekyll |
| 73 | + if: steps.diffs.outputs.diff == 'true' |
| 74 | + working-directory: ./json-manifest-reference |
| 75 | + run: bundle exec jekyll build |
| 76 | + |
| 77 | + - name: Move new built schemas into ./docs/manifest/json-ref |
| 78 | + if: steps.diffs.outputs.diff == 'true' |
| 79 | + # TODO: ideally we don't hardcode these paths, but we need to sort out a fix in the docs |
| 80 | + run: | |
| 81 | + cp ./json-manifest-reference/_site/manifest-def.html ./docs/manifest/json-ref |
| 82 | + cp ./json-manifest-reference/_site/reader.html ./docs/manifest/json-ref |
| 83 | + cp ./json-manifest-reference/_site/settings.html ./docs/manifest/json-ref |
| 84 | +
|
| 85 | + - name: Send schema PR |
| 86 | + if: steps.diffs.outputs.diff == 'true' |
| 87 | + uses: peter-evans/create-pull-request@v7 |
| 88 | + with: |
| 89 | + title: 'docs(schema): update schemas to ${{ env.latest_tag }}' |
| 90 | + body: 'Updates schemas to ${{ env.latest_tag }}.' |
| 91 | + commit-message: 'docs(schema): update schemas to ${{ env.latest_tag }}' |
| 92 | + branch: 'schema-${{ env.latest_tag }}' |
| 93 | + add-paths: ./docs/manifest/json-ref/* |
| 94 | + base: ${{ github.event.repository.default_branch }} |
0 commit comments