Skip to content

feat(activeCampaign): add community plugin registry entry (#64) #62

feat(activeCampaign): add community plugin registry entry (#64)

feat(activeCampaign): add community plugin registry entry (#64) #62

Workflow file for this run

name: Publish Community Plugin
on:
push:
branches:
- main
paths:
- "plugins.json"
- ".gitmodules"
- "packages/tools/**"
- ".github/workflows/publish.yml"
- "scripts/plugin.ts"
- "scripts/publish.ts"
permissions:
contents: write
concurrency:
group: community-plugin-lifecycle-${{ github.ref_name }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
sparse-checkout-cone-mode: false
sparse-checkout: |
/*
!/packages/tools/*
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.28.2
- name: Configure npm auth
shell: bash
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
set -euo pipefail
if [ -n "${NPM_TOKEN:-}" ]; then
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
fi
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Publish pending and stale active plugins
id: publish
env:
BASE_SHA: ${{ github.event.before }}
HEAD_SHA: ${{ github.sha }}
MARKETPLACE_BASE_URL: ${{ secrets.MARKETPLACE_BASE_URL }}
MARKETPLACE_AUTH: ${{ secrets.MARKETPLACE_AUTH }}
shell: bash
run: |
set -euo pipefail
pnpm run plugin -- publish-pending \
--base "$BASE_SHA" \
--head "$HEAD_SHA" \
--all-pending \
--reconcile-active \
--actor "${{ github.actor }}"
if [ -d dist/receipts ]; then
published_count=$(find dist/receipts -name publish-receipt.json -type f | wc -l | tr -d ' ')
else
published_count=0
fi
published_plugins=$(node -e "const fs = require('node:fs'); const path = require('node:path'); const root = 'dist/receipts'; const receipts = []; function walk(dir) { if (!fs.existsSync(dir)) return; for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { const file = path.join(dir, entry.name); if (entry.isDirectory()) walk(file); else if (entry.name === 'publish-receipt.json') receipts.push(JSON.parse(fs.readFileSync(file, 'utf8')).pluginId); } } walk(root); console.log(receipts.join(','));")
echo "published_count=$published_count" >> "$GITHUB_OUTPUT"
echo "published_plugins=$published_plugins" >> "$GITHUB_OUTPUT"
- name: Commit lifecycle state
if: ${{ steps.publish.outputs.published_count != '0' }}
env:
PUBLISHED_PLUGINS: ${{ steps.publish.outputs.published_plugins }}
shell: bash
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add plugins.json events
if git diff --cached --quiet; then
echo "No lifecycle state changes to commit."
exit 0
fi
git commit -m "Publish community plugins ${PUBLISHED_PLUGINS}"
git push origin "HEAD:${GITHUB_REF_NAME}"
- name: Upload receipts
if: ${{ steps.publish.outputs.published_count != '0' }}
uses: actions/upload-artifact@v4
with:
name: publish-receipts
path: dist/receipts
if-no-files-found: error
- name: Upload lifecycle events
if: ${{ steps.publish.outputs.published_count != '0' }}
uses: actions/upload-artifact@v4
with:
name: lifecycle-events
path: events
if-no-files-found: error