Skip to content

Commit

Permalink
feat: Events: Auto PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Giffard <[email protected]>
  • Loading branch information
Mulugruntz committed Feb 26, 2024
1 parent 3192655 commit d604d8e
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,19 @@ on:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/dvalin-tools-event-agent
IMAGE_NAME: dvalin-tools-event-agent
IMAGE_NAME_DOUBLE_DASH: dvalin--tools--event--agent
TAG_NAME: ${{ github.repository_owner }}/dvalin-tools-event-agent
COMMENT_ANCHOR: "<!--- This comment is auto-generated by a GitHub Action :: ${{ github.repository_owner }}/dvalin-tools-event-agent --->"

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
packages: write
pull-requests: write
steps:

- name: Checkout repository
Expand All @@ -36,7 +41,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: ${{ env.REGISTRY }}/${{ env.TAG_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
Expand All @@ -53,3 +58,43 @@ jobs:
target: runtime-prod
build-args: |
DVALIN_REPO_ROOT_DIR=/usr/src/repo/dvalin-data
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: ${{ env.COMMENT_ANCHOR }}

- name: Add PR comment with Docker image info
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
reactions: rocket
body: |
${env.COMMENT_ANCHOR}
:whale: Docker image for PR #${{ github.event.pull_request.number }} has been built and pushed!
![Static Badge][badge-docker-pr]
**Image:** `${{ env.REGISTRY }}/${{ env.TAG_NAME }}:pr-${{ github.event.pull_request.number }}`
Install from the command line
```bash
docker pull ${{ env.REGISTRY }}/${{ env.TAG_NAME }}:pr-${{ github.event.pull_request.number }}
```
Use as base image in Dockerfile:
```Dockerfile
FROM ${{ env.REGISTRY }}/${{ env.TAG_NAME }}:pr-${{ github.event.pull_request.number }}
```
For more details, visit our [GitHub Packages][gh-packages].
[gh-packages]: https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }}
[badge-docker-pr]: https://img.shields.io/badge/${{ env.IMAGE_NAME_DOUBLE_DASH }}-PR--${{ github.event.pull_request.number }}-blue?logo=docker

0 comments on commit d604d8e

Please sign in to comment.