Skip to content

Commit

Permalink
Add Docker release workflow for automated image builds (#105)
Browse files Browse the repository at this point in the history
### TL;DR

Added a GitHub Actions workflow for Docker image release

### What changed?

- Created a new GitHub Actions workflow file `.github/workflows/docker-release.yml` for automated Docker image building and pushing on release events.
- The workflow uses Docker Buildx, logs into Docker Hub, extracts metadata, and builds/pushes the image with appropriate tags and labels.

### How to test?

1. Create a new release or manually trigger the workflow.
2. Verify that the GitHub Action runs successfully.
3. Check Docker Hub to ensure the new image is pushed with the correct tags.

### Why make this change?

This change automates the Docker image release process, ensuring consistent and reliable deployments. It streamlines the release workflow, reducing manual intervention and potential errors during the release process.
  • Loading branch information
iuwqyir authored Oct 17, 2024
2 parents 0f4dd40 + e169a58 commit b8040d1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.env
.mockery.yaml

configs/secrets*
configs/secrets*
39 changes: 39 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Docker Release

on:
release:
types: [published]
workflow_dispatch:

env:
DOCKER_IMAGE: thirdweb/indexer

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXPOSE 8080

ENTRYPOINT ["/bin/app"]

CMD []
CMD []

0 comments on commit b8040d1

Please sign in to comment.