Skip to content

Commit db60427

Browse files
committed
feat: print built docker image to prs when complete
1 parent a41e7ca commit db60427

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ inputs:
3737
description: 'Prefix to add to generated docker tag'
3838
required: false
3939
default: ''
40+
GITHUB_TOKEN:
41+
description: 'Github token of the repository (automatically created by Github)'
42+
default: ${{ github.token }}
43+
required: false
4044
outputs:
4145
tag: # id of output
4246
description: 'Tag used for the docker image'
@@ -103,3 +107,14 @@ runs:
103107
- name: Image digest
104108
run: echo ${{ steps.docker_build.outputs.digest }}
105109
shell: bash
110+
- name: Comment latest docker image
111+
if: github.event_name == 'pull_request'
112+
shell: bash
113+
run: |
114+
# Use GitHub API to create a comment on the PR
115+
PR_NUMBER=${{ github.event.pull_request.number }}
116+
COMMENT='Docker image built: `${{ steps.meta.outputs.tags }}`'
117+
GITHUB_TOKEN=${{ inputs.GITHUB_TOKEN }}
118+
COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments"
119+
120+
curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"${COMMENT}\"}"

0 commit comments

Comments
 (0)