From d0f969e5412255aed99c9647574b73743084363f Mon Sep 17 00:00:00 2001 From: Brian Ginsburg <7957636+bgins@users.noreply.github.com> Date: Mon, 4 Mar 2024 19:05:59 -0800 Subject: [PATCH] chore: Add release-plz schema action run (#594) # Description This PR makes the following changes: - [x] Update schemas action to run on `release-plz` branches on manifest changes only - [x] Update schemas action to run on `main` for both manifest and Rust changes `release-plz` updates versions that we reference in schemas, which put the versions in the schemas out of date. This PR updates the action to handle version changes. ## Type of change - [x] Refactor (non-breaking change that updates existing functionality) --- .github/workflows/schemas.yml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/schemas.yml b/.github/workflows/schemas.yml index bd93ea7f..48561150 100644 --- a/.github/workflows/schemas.yml +++ b/.github/workflows/schemas.yml @@ -2,7 +2,7 @@ name: 📄 Schemas on: push: - branches: [main] + branches: [main, "release-plz-*"] # branches: [main, "**"] permissions: @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest outputs: rust: ${{ steps.filter.outputs.rust }} + manifest: ${{ steps.filter.outputs.manifest }} steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -26,10 +27,12 @@ jobs: - 'homestar-runtime/src/**' - 'homestar-schemas/src/**' - 'homestar-workflow/src/**' + manifest: + - 'Cargo.toml' schemas: needs: changes - if: ${{ needs.changes.outputs.rust == 'true' }} + if: ${{ needs.changes.outputs.rust == 'true' || needs.changes.outputs.manifest == 'true' }} env: SCCACHE_GHA_ENABLED: "true" RUSTC_WRAPPER: "sccache" @@ -58,12 +61,29 @@ jobs: run: cargo run -p homestar-schemas - name: Check for modified schemas - id: git-check + id: git-check-schemas shell: bash run: echo modified=$(if [[ $(git diff homestar-runtime/schemas/) ]]; then echo "true"; else echo "false"; fi) >> $GITHUB_OUTPUT - - name: Push changes - if: steps.git-check.outputs.modified == 'true' + - name: Push changes to main + if: >- + ${{ github.ref_name == 'main' && + (steps.git-check-schemas.outputs.modified == 'true' && + (needs.changes.outputs.rust == 'true' || needs.changes.outputs.manifest == 'true') + ) + }} + run: | + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git + git commit -am "chore(schemas): update OpenRPC API doc and JSON schemas" + git push + + - name: Push changes to release-plz branch + if: >- + ${{ startsWith(github.ref_name, 'release-plz') && + (steps.git-check-schemas.outputs.modified == 'true' && needs.changes.outputs.manifest == 'true') + }} run: | git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"