From 027ad29a7bc34d031ff244a1e9b143d938f7c83e Mon Sep 17 00:00:00 2001 From: Daniel Saeuberli Date: Mon, 14 Sep 2026 13:43:56 +0200 Subject: [PATCH 1/2] Add automatic synchronization from Accelerate upstream --- .github/workflows/sync-from-accelerate.yml | 148 +++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 .github/workflows/sync-from-accelerate.yml diff --git a/.github/workflows/sync-from-accelerate.yml b/.github/workflows/sync-from-accelerate.yml new file mode 100644 index 0000000..3ef9687 --- /dev/null +++ b/.github/workflows/sync-from-accelerate.yml @@ -0,0 +1,148 @@ +# SPDX-License-Identifier: MIT +# +# Pull-based mirror of the canonical Accelerate upstream. +# Uses only GitHub-hosted Actions, git and the GitHub CLI. No external service +# or cross-organisation secret is required. +# +# A sync never writes directly to main. It validates the synchronized tree, +# updates sync/accelerate-main and opens or refreshes a pull request. + +name: Sync from Accelerate upstream + +on: + schedule: + - cron: "*/5 * * * *" + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + statuses: write + +concurrency: + group: sync-from-accelerate + cancel-in-progress: true + +env: + UPSTREAM_REPOSITORY: Accelerate-GmbH/industry-function-graph + SYNC_BRANCH: sync/accelerate-main + +jobs: + sync: + runs-on: ubuntu-latest + + steps: + - name: Checkout DIDAS + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Prepare synchronization branch + run: git checkout -B "$SYNC_BRANCH" origin/main + + - name: Fetch canonical Accelerate upstream + run: | + git clone --depth 1 "https://github.com/$UPSTREAM_REPOSITORY.git" "$RUNNER_TEMP/upstream" + echo "UPSTREAM_SHA=$(git -C "$RUNNER_TEMP/upstream" rev-parse HEAD)" >> "$GITHUB_ENV" + + - name: Synchronize repository tree + run: | + rsync -a --delete \ + --exclude='.git/' \ + --exclude='.github/deploy-pages.yml.disabled' \ + --exclude='.github/workflows/deploy-pages.yml' \ + --exclude='.github/workflows/sync-from-accelerate.yml' \ + "$RUNNER_TEMP/upstream/" ./ + + # DIDAS owns publication and synchronization. Those workflows are + # intentionally not mirrored from the Accelerate source repository. + git checkout origin/main -- \ + '.github/workflows/deploy-pages.yml' \ + '.github/workflows/sync-from-accelerate.yml' + rm -f '.github/deploy-pages.yml.disabled' + + - name: Detect drift + id: drift + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + git status --short + else + echo "changed=false" >> "$GITHUB_OUTPUT" + echo "DIDAS already matches Accelerate upstream." + fi + + - name: Set up Python + if: steps.drift.outputs.changed == 'true' + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Validate synchronized graph + if: steps.drift.outputs.changed == 'true' + run: | + pip install rdflib pyshacl + python3 build/validate.py + python3 build/queries.py --check + python3 build/build.py --check + + - name: Commit synchronized tree + if: steps.drift.outputs.changed == 'true' + run: | + git config user.name "danielsaeuberli" + git config user.email "249639066+danielsaeuberli@users.noreply.github.com" + git add -A + git commit -m "Sync from Accelerate upstream" \ + -m "Source: https://github.com/$UPSTREAM_REPOSITORY/commit/$UPSTREAM_SHA" + git push --force origin "$SYNC_BRANCH" + echo "SYNC_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV" + + - name: Record successful synchronization validation + if: steps.drift.outputs.changed == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + gh api --method POST \ + "repos/$GITHUB_REPOSITORY/statuses/$SYNC_SHA" \ + -f state=success \ + -f context='upstream-sync/validated' \ + -f description='Accelerate upstream synchronized and repository checks passed' + + - name: Create or refresh synchronization pull request + if: steps.drift.outputs.changed == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + BODY=$(cat </dev/null); then + gh pr edit "$NUMBER" \ + --title "Sync from Accelerate upstream" \ + --body "$BODY" + else + gh pr create \ + --base main \ + --head "$SYNC_BRANCH" \ + --title "Sync from Accelerate upstream" \ + --body "$BODY" + fi + + - name: Close stale synchronization PR when no drift remains + if: steps.drift.outputs.changed == 'false' + env: + GH_TOKEN: ${{ github.token }} + run: | + if NUMBER=$(gh pr view "$SYNC_BRANCH" --json number --jq .number 2>/dev/null); then + gh pr close "$NUMBER" --comment "No upstream drift remains; closing the synchronization PR." + fi From 8906c2a32d7050bfce7eb5982102b73c9b9e6f54 Mon Sep 17 00:00:00 2001 From: Daniel Saeuberli Date: Mon, 14 Sep 2026 13:45:03 +0200 Subject: [PATCH 2/2] Run the upstream synchronization check daily --- .github/workflows/sync-from-accelerate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-from-accelerate.yml b/.github/workflows/sync-from-accelerate.yml index 3ef9687..9301578 100644 --- a/.github/workflows/sync-from-accelerate.yml +++ b/.github/workflows/sync-from-accelerate.yml @@ -11,7 +11,7 @@ name: Sync from Accelerate upstream on: schedule: - - cron: "*/5 * * * *" + - cron: "17 5 * * *" workflow_dispatch: permissions: