From 544f616845356964a16355468ceedeaed5292428 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 29 Jan 2025 08:17:10 +0900 Subject: [PATCH] ci: Remove not triggered manifest_sync workflow --- .github/workflows/manifest_sync.yml | 51 --------------------- tools/ci/checkout-manifest-schema-branch.sh | 28 ----------- tools/publish.sh | 41 +++++++++++++++++ 3 files changed, 41 insertions(+), 79 deletions(-) delete mode 100644 .github/workflows/manifest_sync.yml delete mode 100755 tools/ci/checkout-manifest-schema-branch.sh diff --git a/.github/workflows/manifest_sync.yml b/.github/workflows/manifest_sync.yml deleted file mode 100644 index 5b87f2f4b..000000000 --- a/.github/workflows/manifest_sync.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Manifest Synchronization - -permissions: - contents: read - -on: - release: - types: [published] - -env: - WORKSPACE: /tmp/workspace - -defaults: - run: - shell: bash --noprofile --norc -CeEuxo pipefail {0} - -jobs: - sync: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: true - - - name: Checkout manifest-schema branch - run: ./tools/ci/checkout-manifest-schema-branch.sh "${WORKSPACE}" - - - name: Copy over schema - run: cp -- ./manifests/* "${WORKSPACE}" - - - name: Stage changes - working-directory: ${{ env.WORKSPACE }} - run: git add . - - - name: Show diff - working-directory: ${{ env.WORKSPACE }} - run: git diff HEAD - - - name: Detect changes - id: changes - working-directory: ${{ env.WORKSPACE }} - run: | - # This output boolean tells us if the dependencies have actually changed - printf "count=%s\n" "$(git status --porcelain=v1 | wc -l)" >>"${GITHUB_OUTPUT}" - - - name: Commit and push - # Only push if changes exist - if: steps.changes.outputs.count > 0 - working-directory: ${{ env.WORKSPACE }} - run: | - git commit -m "Update manifest schema" && git push origin HEAD diff --git a/tools/ci/checkout-manifest-schema-branch.sh b/tools/ci/checkout-manifest-schema-branch.sh deleted file mode 100755 index f96630ab0..000000000 --- a/tools/ci/checkout-manifest-schema-branch.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: Apache-2.0 OR MIT -set -CeEuo pipefail -IFS=$'\n\t' -trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR -cd -- "$(dirname -- "$0")" - -version="$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "install-action-manifest-schema") | .version')" -if [[ "${version}" == "0."* ]]; then - schema_version="0.$(cut -d. -f2 <<<"${version}")" -else - schema_version="$(cut -d. -f1 <<<"${version}")" -fi -branch="manifest-schema-${schema_version}" - -git worktree add --force "${1?}" -cd -- "$1" - -if git fetch origin "${branch}"; then - git checkout "origin/${branch}" -B "${branch}" -elif ! git checkout "${branch}"; then - # New branch with no history. Credit: https://stackoverflow.com/a/13969482 - git checkout --orphan "${branch}" - git rm -rf . || true - git config --local user.name github-actions - git config --local user.email github-actions@github.com - git commit -m 'Initial commit' --allow-empty -fi diff --git a/tools/publish.sh b/tools/publish.sh index 7e92e6c13..14ef81206 100755 --- a/tools/publish.sh +++ b/tools/publish.sh @@ -158,3 +158,44 @@ for tool in "${tools[@]}"; do git checkout main git branch -D "${tool}" done + +schema_workspace=/tmp/workspace +rm -rf -- "${schema_workspace}" +# Checkout manifest-schema branch +schema_version="$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "install-action-manifest-schema") | .version')" +if [[ "${schema_version}" == "0."* ]]; then + schema_version="0.$(cut -d. -f2 <<<"${schema_version}")" +else + schema_version="$(cut -d. -f1 <<<"${schema_version}")" +fi +schema_branch="manifest-schema-${schema_version}" + +git worktree add --force "${schema_workspace}" +( + cd -- "${schema_workspace}" + if git fetch origin "${schema_branch}"; then + git checkout "origin/${schema_branch}" -B "${schema_branch}" + elif ! git checkout "${schema_branch}"; then + # New branch with no history. Credit: https://stackoverflow.com/a/13969482 + git checkout --orphan "${schema_branch}" + git rm -rf -- . || true + git commit -m 'Initial commit' --allow-empty + fi +) + +# Copy over schema +cp -- ./manifests/* "${schema_workspace}" + +( + cd -- "${schema_workspace}" + # Stage changes + git add . + # Detect changes, then commit and push if changes exist + if [[ "$(git status --porcelain=v1 | wc -l)" != "0" ]]; then + git commit -m 'Update manifest schema' + git push origin HEAD + fi +) + +rm -rf -- "${schema_workspace}" +git worktree prune