diff --git a/.github/workflows/expert-cd.yml b/.github/workflows/expert-cd.yml index 1cabfc95..28ac6ea2 100644 --- a/.github/workflows/expert-cd.yml +++ b/.github/workflows/expert-cd.yml @@ -16,7 +16,6 @@ jobs: definition: - name: create-expert path: definitions/create-expert - draft-id: ${{ vars.EXPERT_DRAFT_ID_CREATE_EXPERT }} steps: - uses: actions/checkout@v6 @@ -45,28 +44,43 @@ jobs: echo "should-publish=true" >> "$GITHUB_OUTPUT" fi - - name: Publish scope if private + - name: Resolve draft ID if: steps.check.outputs.should-publish == 'true' + id: draft run: | - bun ./apps/perstack/bin/cli.ts expert publish ${{ matrix.definition.name }} \ - --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }} || true + OUTPUT=$(bun ./apps/perstack/bin/cli.ts expert list --filter ${{ matrix.definition.name }} \ + --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }}) + echo "$OUTPUT" + DRAFT_ID=$(echo "$OUTPUT" | grep "ID:" | head -1 | awk '{print $2}') + if [ -z "$DRAFT_ID" ]; then + echo "::error::Draft scope not found for ${{ matrix.definition.name }}" + exit 1 + fi + echo "draft-id=$DRAFT_ID" >> "$GITHUB_OUTPUT" + echo "Resolved draft ID: $DRAFT_ID" - name: Push to draft if: steps.check.outputs.should-publish == 'true' id: push run: | - OUTPUT=$(bun ./apps/perstack/bin/cli.ts expert push ${{ matrix.definition.draft-id }} \ + OUTPUT=$(bun ./apps/perstack/bin/cli.ts expert push ${{ steps.draft.outputs.draft-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: | + bun ./apps/perstack/bin/cli.ts expert publish ${{ matrix.definition.name }} \ + --api-key ${{ secrets.PERSTACK_PRODUCTION_API_KEY }} || true + - name: Assign version if: steps.check.outputs.should-publish == 'true' run: | bun ./apps/perstack/bin/cli.ts expert version \ - ${{ matrix.definition.draft-id }} \ + ${{ steps.draft.outputs.draft-id }} \ ${{ steps.push.outputs.ref-id }} \ ${{ steps.version.outputs.version }} \ --tag latest \