From 23a90586b200a08be4accd7895bfdfbea573d341 Mon Sep 17 00:00:00 2001 From: Sahil Ahuja Date: Thu, 6 Mar 2025 22:46:33 +0530 Subject: [PATCH] New commit messages --- .github/workflows/cs-update-push.yml | 30 +++++++++++++++++-------- .github/workflows/cs-update-trigger.yml | 18 ++++++--------- .github/workflows/nm-update.yml | 2 ++ src/cs_to_nm.sh | 2 -- src/repo_to_cs.sh | 4 ++-- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/cs-update-push.yml b/.github/workflows/cs-update-push.yml index b7fb0ed..1cc9862 100644 --- a/.github/workflows/cs-update-push.yml +++ b/.github/workflows/cs-update-push.yml @@ -21,15 +21,21 @@ jobs: name: Read the issue comment run: | ISSUE_COMMENT_STRING='${{ github.event.comment.body }}' - DOCKER_BASE=`echo $ISSUE_COMMENT_STRING | jq ".image"` - BUILD_ID=`echo $ISSUE_COMMENT_STRING | jq ".tag"` - echo "DOCKER_BASE=$DOCKER_BASE" >> "$GITHUB_OUTPUT"; - echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT"; + TAG=`echo $ISSUE_COMMENT_STRING | jq ".tag"` + REPO=`echo $ISSUE_COMMENT_STRING | jq ".repo"` + SENDER=`echo $ISSUE_COMMENT_STRING | jq ".sender"` + DOCKER_REPO=${{ vars.docker_repo2_registry }}/$REPO_NAME + echo "TAG=$TAG" >> "$GITHUB_OUTPUT"; + echo "REPO=$REPO" >> "$GITHUB_OUTPUT"; + echo "SENDER=$SENDER" >> "$GITHUB_OUTPUT"; + echo "DOCKER_REPO=$DOCKER_REPO" >> "$GITHUB_OUTPUT"; - name: Print IMAGE and TAG run: | - echo "BUILD_ID: ${{ steps.read-issue.outputs.BUILD_ID }}"; - echo "DOCKER_BASE: ${{ steps.read-issue.outputs.DOCKER_BASE }}"; + echo "TAG: ${{ steps.read-issue.outputs.TAG }}"; + echo "REPO: ${{ steps.read-issue.outputs.REPO }}"; + echo "SENDER: ${{ steps.read-issue.outputs.SENDER }}"; + echo "DOCKER_REPO: ${{ steps.read-issue.outputs.DOCKER_REPO }}"; - name: Checkout cs repo uses: actions/checkout@v4 @@ -56,13 +62,19 @@ jobs: git config --global user.name 'bot-build' git config --global user.email 'techbots+build@gmetri.com' - BUILD_ID=${{ steps.read-issue.outputs.BUILD_ID }} - DOCKER_BASE=${{ steps.read-issue.outputs.DOCKER_BASE }} + TAG=${{ steps.read-issue.outputs.TAG }} + REPO=${{ steps.read-issue.outputs.REPO }} + SENDER=${{ steps.read-issue.outputs.SENDER }} + DOCKER_REPO=${{ steps.read-issue.outputs.DOCKER_REPO }} REPOLIST=./.github/repolist.txt pwd; ls -al; cd cs; - ../deploy-tools/src/repo_to_cs.sh -m $DOCKER_BASE -t $BUILD_ID -r $REPOLIST; + source ../deploy-tools/src/repo_to_cs.sh -m $DOCKER_REPO -t $TAG -r $REPOLIST; + echo "NEW_TAG: $NEW_TAG" + COMMIT_MESSAGE="$NEW_TAG: $REPO to $TAG by $SENDER"; + git commit -m "$COMMIT_MESSAGE" + git tag -a $NEW_TAG -m "$COMMIT_MESSAGE" git push origin main; git push --tags origin main; diff --git a/.github/workflows/cs-update-trigger.yml b/.github/workflows/cs-update-trigger.yml index cfa29ae..23893fc 100644 --- a/.github/workflows/cs-update-trigger.yml +++ b/.github/workflows/cs-update-trigger.yml @@ -11,7 +11,7 @@ on: type: string env: - CS_REPO: ${{ github.repository }} + REPO: ${{ github.repository }} jobs: trigger-cs-job: @@ -24,21 +24,17 @@ jobs: run: | SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }}; BUILD_ID=$BRANCH_NAME-${SHA:0:8}; - DOCKER_BASE=${{ vars.docker_repo2_registry }}/$CS_REPO - DOCKER_IMAGE=$DOCKER_BASE:$BUILD_ID; - echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT"; - echo "DOCKER_BASE=$DOCKER_BASE" >> "$GITHUB_OUTPUT"; - echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT"; + echo "REPO=$REPO >> $GITHUB_OUTPUT" + echo "TAG=$BUILD_ID" >> "$GITHUB_OUTPUT"; - - name: Print build id and image name + - name: Print repo and build_id run: | - echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}"; - echo "DOCKER_BASE: ${{ steps.get-id.outputs.DOCKER_BASE }}"; - echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}"; + echo "REPO: ${{ steps.get-id.outputs.REPO }}"; + echo "TAG: ${{ steps.get-id.outputs.TAG }}"; - 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` + ISSUE_COMMENT_STRING=`echo "{ \"repo\": \"${{ steps.get-id.outputs.REPO }}"\, \"tag\": \"${{ steps.get-id.outputs.TAG }}\", \"sender\": \"${{ github.event.sender.login }}\" }" | jq tostring` echo ISSUE_COMMENT_STRING: $ISSUE_COMMENT_STRING API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring` diff --git a/.github/workflows/nm-update.yml b/.github/workflows/nm-update.yml index 5dca252..d11fae1 100644 --- a/.github/workflows/nm-update.yml +++ b/.github/workflows/nm-update.yml @@ -77,4 +77,6 @@ jobs: cd nm; CS_LIST=./.github/cslist.txt; ../deploy-tools/src/cs_to_nm.sh -c ${{ env.CS_REPO }} -v $VERSION -k $CS_LIST; + + git commit -m "$CS_REPO_NAME to $VERSION by ${{ github.event.sender.login }}" git push origin main; diff --git a/src/cs_to_nm.sh b/src/cs_to_nm.sh index 6084aea..f7afbc1 100755 --- a/src/cs_to_nm.sh +++ b/src/cs_to_nm.sh @@ -34,8 +34,6 @@ main() sed -i -e "s/${SEARCH_STRING}.*/${SEARCH_STRING}${VERSION}/" $KUST_PATH git add $KUST_PATH done <<< "$CSLIST" - - git commit -m "$CS_REPO_NAME updated to $VERSION" } ### Starts here diff --git a/src/repo_to_cs.sh b/src/repo_to_cs.sh index 4652319..b060956 100755 --- a/src/repo_to_cs.sh +++ b/src/repo_to_cs.sh @@ -41,8 +41,8 @@ main() source $SCRIPT_DIR/repo_to_cs_basetag.sh; # cat $NEW_TAG > version; #To always allow a commit # git add version; - git commit -m "$NEW_TAG: $IMAGE updated to $IMAGE_TAG"; - git tag -a $NEW_TAG -m "$NEW_TAG: $IMAGE updated to $IMAGE_TAG" + # git commit -m "$NEW_TAG: $IMAGE updated to $IMAGE_TAG"; + # git tag -a $NEW_TAG -m "$NEW_TAG: $IMAGE updated to $IMAGE_TAG" } ### Starts here