Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions .github/workflows/sync-marketplace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Sync plugin SHA to xAI marketplace

# After every push to main, open (or update) a PR against the xAI plugin
# marketplace that re-pins the `apify` plugin entry to the new commit SHA.
#
# Prerequisites:
# 1. A fork of xai-org/plugin-marketplace must exist at $FORK.
# 2. MARKETPLACE_PAT must be a PAT that can push to $FORK and create PRs in $UPSTREAM
# (fine-grained tokens typically must be granted access to both repositories).
# 3. The `apify` entry must already be merged upstream (update-only — it does not create the entry on the first run).

on:
push:
branches: [main]
workflow_dispatch:

# This job only reads this repo; all writes happen against the fork via the PAT.
permissions:
contents: read

concurrency:
group: sync-marketplace
cancel-in-progress: true

env:
UPSTREAM: xai-org/plugin-marketplace
FORK: apify/xaiplugin-marketplace
PLUGIN_NAME: apify
PR_BRANCH: apify/update-sha

jobs:
update-marketplace:
runs-on: ubuntu-latest
steps:
- name: Check out the apify fork of the marketplace
uses: actions/checkout@v4
with:
repository: ${{ env.FORK }}
token: ${{ secrets.MARKETPLACE_PAT }}
path: marketplace
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Sync fork's main onto upstream main
working-directory: marketplace
run: |
git remote add upstream "https://github.com/${UPSTREAM}.git"
git fetch upstream main
git checkout -B main upstream/main

- name: Re-pin the apify entry to this commit
id: update
working-directory: marketplace
run: |
set -euo pipefail
file=".grok-plugin/marketplace.json"

# Update-only: bail out cleanly if the entry isn't upstream yet.
if ! jq -e --arg n "$PLUGIN_NAME" 'any(.plugins[]; .name == $n)' "$file" >/dev/null; then
echo "::warning::No '$PLUGIN_NAME' entry found in $UPSTREAM yet — submit the first PR manually. Skipping."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi

jq --arg n "$PLUGIN_NAME" --arg sha "$GITHUB_SHA" \
'(.plugins[] | select(.name == $n) | .source.sha) = $sha' \
"$file" > "$file.tmp"
mv "$file.tmp" "$file"
echo "skip=false" >> "$GITHUB_OUTPUT"

- name: Regenerate the component index and validate the catalog
if: steps.update.outputs.skip != 'true'
working-directory: marketplace
run: |
python3 scripts/generate-plugin-index.py
python3 scripts/validate-catalog.py

- name: Open or update the marketplace PR
if: steps.update.outputs.skip != 'true'
working-directory: marketplace
env:
GH_TOKEN: ${{ secrets.MARKETPLACE_PAT }}
run: |
set -euo pipefail

if git diff --quiet; then
echo "marketplace.json is already pinned to ${GITHUB_SHA}; nothing to do."
exit 0
fi

git config user.name "apify-bot"
git config user.email "actions@apify.com"
git checkout -B "$PR_BRANCH"
git add -A
git commit -m "chore(${PLUGIN_NAME}): pin plugin to ${GITHUB_SHA}"
git push --force origin "$PR_BRANCH"

fork_owner="${FORK%%/*}"
short_sha="${GITHUB_SHA:0:7}"
existing="$(gh pr list --repo "$UPSTREAM" \
--head "${fork_owner}:${PR_BRANCH}" --state open \
--json number --jq 'length')"

if [ "$existing" = "0" ]; then
body="Automated re-pin of the \`${PLUGIN_NAME}\` plugin to [\`${short_sha}\`](https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}), opened by the \`sync-marketplace\` workflow in \`${GITHUB_REPOSITORY}\`."
gh pr create --repo "$UPSTREAM" \
--base main \
--head "${fork_owner}:${PR_BRANCH}" \
--title "chore(${PLUGIN_NAME}): update plugin SHA to ${short_sha}" \
--body "$body"
else
echo "An open PR already exists; the force-push above updated it."
fi
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ The executable requirements come from the skills themselves: Route 1 uses the MC
- Source repo — [github.com/apify/apify-grok-build-plugin](https://github.com/apify/apify-grok-build-plugin)
- Issues / feedback — open an issue on the source repo, or email [support@apify.com](mailto:support@apify.com)

## Publishing

This plugin is distributed through the [xAI Plugin Marketplace](https://github.com/xai-org/plugin-marketplace),
pinned to a commit SHA of this repo. A GitHub Actions workflow re-pins the entry
automatically on every push to `main`. See [.github/workflows/sync-marketplace.yml](.github/workflows/sync-marketplace.yml)
for prerequisites and the submission flow.

## License

Apache-2.0. See [LICENSE](./LICENSE).
Loading