Skip to content

Commit

Permalink
Add docker image publishing to release workflow with tagging (#91)
Browse files Browse the repository at this point in the history
ci(workflows): add trigger for Docker Publish Workflow on new release
creation
ci(workflows): update Docker image build and push actions to include
version tag
ci(workflows): add support for building and pushing Docker image with
nightly tag

The changes were made to enhance the CI workflows related to creating
new releases and publishing Docker images. The trigger for the Docker
Publish Workflow was added to the create-new-release.yml file to
automate the process of publishing Docker images when a new release is
created. Additionally, the publish-docker-image.yml file was updated to
include support for building and pushing Docker images with version tags
and a nightly tag based on the event payload. This improves the
automation and versioning of Docker images in the CI pipeline.
  • Loading branch information
mauvehed authored May 24, 2024
2 parents 8c6fdd0 + 37ed6b0 commit e0681a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/create-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ jobs:
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Trigger Docker Publish Workflow
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
event-type: publish-docker-image
client-payload: '{"tag": "${{ github.ref }}"}'
17 changes: 15 additions & 2 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
paths:
- 'Dockerfile'
- '.github/workflows/publish-docker-image.yml'
# Triggered by a repository_dispatch event to allow external systems to initiate the workflow
repository_dispatch:
types: [publish-docker-image]

jobs:
build-and-publish:
Expand All @@ -27,12 +30,22 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
- name: Build and push Docker image with version tag
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/yourip:latest
tags: |
ghcr.io/${{ github.repository_owner }}/yourip:${{ github.event.client_payload.tag }}
ghcr.io/${{ github.repository_owner }}/yourip:latest
- name: Build and push Docker image with nightly tag
if: github.event.client_payload.tag == 'nightly'
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ghcr.io/${{ github.repository_owner }}/yourip:nightly

- name: Logout from GHCR
run: docker logout ghcr.io

0 comments on commit e0681a9

Please sign in to comment.