New cs-trigger

This commit is contained in:
Sahil Ahuja 2025-02-13 23:45:54 +05:30
parent 76e3873f79
commit 8ad08afcf4
4 changed files with 86 additions and 4 deletions

78
.github/unused/sh/trigger.sh vendored Normal file
View File

@ -0,0 +1,78 @@
#!/bin/bash
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
-d '{"ref":"main","inputs":{"image":"${{ inputs.image }}","tag":"${{ inputs.tag }}"}}';
repo2.hub.gmetri.io/dt-api
main-fda468af
Token (DUMMY): e139b1c73bfae1b7748961c9f9a381bd3cca0633
https://git.gmetri.io/gmetrivr/cs-dt/actions/run?workflow=update-repo-version.yml&actor=0&status=
curl -X 'POST' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues' \
-H 'accept: application/json' \
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
-H 'Content-Type: application/json' \
-d '{
"assignee": "bot-build",
"body": "{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-fda468af\"}",
"closed": false,
"title": "cs-dt package for repo2.hub.gmetri.io/dt-api:main-fda468af"
}'
curl -X 'POST' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
-d '{
"body": "{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-fda468af\"}"
}'
curl -X 'POST' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
-H 'accept: application/json' \
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
-H 'Content-Type: application/json' \
-d '{
"body": "{\"image\":\"repo2.hub.gmetri.io\/dt-api\",\"tag\":\"main-255c2f30\"}"
}'
ISSUE_COMMENT_STRING=`echo '{ "image": "repo2.hub.gmetri.io/dt-api", "tag": "main-255c2f30" }' | jq tostring`
API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring`
# {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}
curl -X 'POST' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
-H 'accept: application/json' \
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
-H 'Content-Type: application/json' \
-d $API_JSON_BODY
curl -X 'POST' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/1/comments' \
-H 'accept: application/json' \
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
-H 'Content-Type: application/json' \
-d '{"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}'
#Get the latest issue with label workflow
ISSUE_JSON=`curl -X 'GET' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-ui/issues?labels=workflow&page=1&limit=1' \
-H 'accept: application/json' \
-H 'Authorization: token 20daafd0fb3dd3392738430bf438eb96023b5cb0'`
ISSUE_NUMBER=`echo $ISSUE_JSON | jq '.[0].number'`
curl -X 'POST' \
'https://git.gmetri.io/api/v1/repos/gmetrivr/cs-dt/issues/$ISSUE_NUMBER/comments' \
-H 'accept: application/json' \
-H 'Authorization: token e139b1c73bfae1b7748961c9f9a381bd3cca0633' \
-H 'Content-Type: application/json' \
-d '{"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}'

View File

@ -36,7 +36,7 @@ jobs:
echo "DOCKER_BASE: ${{ steps.get-id.outputs.DOCKER_BASE }}";
echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}";
- name: Push image name and tag to cs repo's issue#1
- name: Push image name and tag to cs repo's latest issue with label workflow
run: |
ISSUE_COMMENT_STRING=`echo "{ \"image\": \"${{ steps.get-id.outputs.DOCKER_BASE }}\", \"tag\": \"${{ steps.get-id.outputs.BUILD_ID }}\" }" | jq tostring`
echo ISSUE_COMMENT_STRING: $ISSUE_COMMENT_STRING
@ -45,12 +45,16 @@ jobs:
echo API_JSON_BODY: $API_JSON_BODY
# {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"}
set +x
set -x
ISSUE_JSON=`curl -X 'GET' \
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues?labels=workflow&page=1&limit=1' \
-H 'accept: application/json' \
-H 'Authorization: token ${{ secrets.bot_build_issues_token }}'`
ISSUE_NUMBER=`echo $ISSUE_JSON | jq '.[0].number'`
curl -X 'POST' \
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues/1/comments' \
'${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues/$ISSUE_NUMBER/comments' \
-H 'accept: application/json' \
-H 'Authorization: token ${{ secrets.bot_build_issues_token }}' \
-H 'Content-Type: application/json' \
-d $API_JSON_BODY
set +x