refactor: slim down plan instruction to focus on test design and veri… #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Expert CD | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'definitions/**/perstack.toml' | |
| jobs: | |
| publish: | |
| name: Publish Expert Definitions | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| matrix: | |
| definition: | |
| - name: create-expert | |
| path: definitions/create-expert | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: definitions | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Extract version from perstack.toml | |
| id: version | |
| run: | | |
| VERSION=$(grep -m1 '^version' ${{ matrix.definition.path }}/perstack.toml | sed 's/.*"\(.*\)".*/\1/') | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Extracted version: $VERSION" | |
| - name: Check if version already exists | |
| id: check | |
| run: | | |
| OUTPUT=$(npx perstack@latest expert versions ${{ matrix.definition.name }} \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }} 2>&1) || true | |
| echo "$OUTPUT" | |
| if echo "$OUTPUT" | grep -q "^ ${{ steps.version.outputs.version }}"; then | |
| echo "Version ${{ steps.version.outputs.version }} already exists — skipping" | |
| echo "should-publish=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "Version ${{ steps.version.outputs.version }} not found — will publish" | |
| echo "should-publish=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Resolve or create draft scope | |
| if: steps.check.outputs.should-publish == 'true' | |
| id: draft | |
| run: | | |
| # Try to find existing draft scope | |
| OUTPUT=$(npx perstack@latest expert list --filter ${{ matrix.definition.name }} \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }}) | |
| echo "$OUTPUT" | |
| DRAFT_SCOPE_ID=$(echo "$OUTPUT" | grep "ID:" | head -1 | awk '{print $2}') | |
| if [ -z "$DRAFT_SCOPE_ID" ]; then | |
| # No draft scope exists — create one | |
| APP_ID=$(npx perstack@latest application list \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }} | grep "ID:" | head -1 | awk '{print $2}') | |
| CREATE_OUTPUT=$(npx perstack@latest expert create ${{ matrix.definition.name }} \ | |
| --app "$APP_ID" \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }}) | |
| echo "$CREATE_OUTPUT" | |
| DRAFT_SCOPE_ID=$(echo "$CREATE_OUTPUT" | grep "ID:" | awk '{print $2}') | |
| fi | |
| echo "draft-scope-id=$DRAFT_SCOPE_ID" >> "$GITHUB_OUTPUT" | |
| echo "Resolved draft scope ID: $DRAFT_SCOPE_ID" | |
| - name: Push to draft | |
| if: steps.check.outputs.should-publish == 'true' | |
| id: push | |
| run: | | |
| OUTPUT=$(npx perstack@latest expert push ${{ steps.draft.outputs.draft-scope-id }} \ | |
| --config ${{ matrix.definition.path }}/perstack.toml \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }}) | |
| echo "$OUTPUT" | |
| REF_ID=$(echo "$OUTPUT" | grep "Ref ID:" | awk '{print $3}') | |
| echo "ref-id=$REF_ID" >> "$GITHUB_OUTPUT" | |
| - name: Publish scope if private | |
| if: steps.check.outputs.should-publish == 'true' | |
| run: | | |
| npx perstack@latest expert publish ${{ matrix.definition.name }} \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }} || true | |
| - name: Assign version | |
| if: steps.check.outputs.should-publish == 'true' | |
| run: | | |
| npx perstack@latest expert version \ | |
| ${{ steps.draft.outputs.draft-scope-id }} \ | |
| ${{ steps.push.outputs.ref-id }} \ | |
| ${{ steps.version.outputs.version }} \ | |
| --tag latest \ | |
| --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }} |