Skip to content

Events: GitHub Action for Docker #16

Events: GitHub Action for Docker

Events: GitHub Action for Docker #16

Workflow file for this run

name: Create and publish a Docker image
on:
push:
branches:
- 'main'
tags:
- 'dvalin-tools-event-agent:v*'
pull_request:
branches:
- 'main'
env:
REGISTRY: ghcr.io
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
uses: actions/checkout@v4
# - name: Log in to the Container registry
# uses: docker/login-action@v3
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v5
# with:
# images: ${{ env.REGISTRY }}/${{ env.TAG_NAME }}
# tags: |
# type=ref,event=branch
# type=ref,event=pr
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}.{{minor}}
#
# - name: Build and push Docker image
# uses: docker/build-push-action@v5
# with:
# context: "{{defaultContext}}:dvalin-tools"
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# 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: Render template
id: template
uses: chuhlomin/[email protected]
with:
template: .github/comment-body-docker.md
vars: |
comment_anchor: "${{ env.COMMENT_ANCHOR }}"
pr_number: "${{ github.event.pull_request.number }}"
docker_image_full: "${{ env.REGISTRY }}/${{ env.TAG_NAME }}:pr-${{ github.event.pull_request.number }}"
link_gh_packages: "https://github.com/${{ github.repository }}/pkgs/container/${{ env.IMAGE_NAME }}"
link_badge_docker_pr: "https://img.shields.io/badge/${{ env.IMAGE_NAME_DOUBLE_DASH }}-PR--${{ github.event.pull_request.number }}-blue?logo=docker"
- 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 }}
body: ${{ steps.template.outputs.result }}
edit-mode: replace
reactions: rocket