name: Reusable container push workflow on: workflow_call: inputs: deploy_repo: description: 'The cs repo that contains this image' required: true type: string env: REPO: ${{ github.repository }} jobs: trigger-cs-job: permissions: issues: write runs-on: ubuntu-22.04 steps: - id: get-id name: Get a unique tag for this build run: | SHA=${{ github.sha }}; BRANCH_NAME=${{ github.base_ref || github.ref_name }}; BUILD_ID=$BRANCH_NAME-${SHA:0:8}; DOCKER_IMAGE=${{ vars.docker_repo2_registry }}/$REPO:$BUILD_ID; echo "BUILD_ID=$BUILD_ID" >> "$GITHUB_OUTPUT"; echo "DOCKER_IMAGE=$DOCKER_IMAGE" >> "$GITHUB_OUTPUT"; - name: Print build id and image name run: | echo "BUILD_ID: ${{ steps.get-id.outputs.BUILD_ID }}"; echo "DOCKER_IMAGE: ${{ steps.get-id.outputs.DOCKER_IMAGE }}"; - name: Push image name and tag to cs repo's issue#1 run: | ISSUE_COMMENT_STRING=`echo "{ \"image\": \"${{ github.repository }}\", \"tag\": \"${{ steps.get-id.outputs.BUILD_ID }}\" }" | jq tostring` echo ISSUE_COMMENT_STRING: $ISSUE_COMMENT_STRING API_JSON_BODY=`echo '{"body": '$ISSUE_COMMENT_STRING' }' | jq -r tostring` echo API_JSON_BODY: $API_JSON_BODY # {"body":"{\"image\":\"repo2.hub.gmetri.io/dt-api\",\"tag\":\"main-255c2f30\"}"} set +x curl -X 'POST' \ '${{ github.api_url }}/repos/${{ inputs.deploy_repo }}/issues/1/comments' \ -H 'accept: application/json' \ -H 'Authorization: token ${{ secrets.bot_build_issues_token }}' \ -H 'Content-Type: application/json' \ -d $API_JSON_BODY set +x