5555 - name : Trigger CircleCI Pipeline
5656 env :
5757 CIRCLECI_TOKEN : ${{ secrets.CIRCLE_CI_TOKEN }}
58- CIRCLE_ID : ${{ secrets.CIRCLE_CI_ID }}
58+ CIRCLE_PROJECT_ID : ${{ secrets.CIRCLE_SLUG }}
5959 if : ${{ steps.get_tag.outputs.tag != '' }}
6060 run : |
6161 VERSION_TAG="${{ steps.get_tag.outputs.tag }}"
@@ -67,20 +67,26 @@ jobs:
6767 IS_LATEST="false"
6868 fi
6969
70- echo "Triggering CircleCI pipeline with:"
71- echo " Version: $VERSION_TAG"
72- echo " Branch: $SOURCE_BRANCH"
73- echo " Is Latest: $IS_LATEST"
74-
75- # Trigger CircleCI pipeline
76- curl -X POST https://circleci.com/api/v2/project/gh/gouda/pipeline \
70+ # Trigger CircleCI pipeline using project ID
71+ RESPONSE=$(curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST \
72+ "https://circleci.com/api/v2/project/$CIRCLE_PROJECT_ID/pipeline" \
7773 -H "Circle-Token: $CIRCLECI_TOKEN" \
7874 -H "Content-Type: application/json" \
7975 -d '{
80- "definition_id": "${{ CIRCLE_ID }}",
8176 "parameters": {
8277 "version_tag": "'"$VERSION_TAG"'",
8378 "is_latest": '"$IS_LATEST"',
8479 "source_branch": "'"$SOURCE_BRANCH"'"
8580 }
86- }'
81+ }')
82+
83+ echo "Response:"
84+ echo "$RESPONSE"
85+
86+ HTTP_STATUS=$(echo "$RESPONSE" | grep "HTTP_STATUS" | cut -d: -f2)
87+ if [ "$HTTP_STATUS" = "201" ] || [ "$HTTP_STATUS" = "200" ]; then
88+ echo "✅ Pipeline triggered successfully!"
89+ else
90+ echo "❌ Failed to trigger pipeline. Status: $HTTP_STATUS"
91+ exit 1
92+ fi
0 commit comments