feat: Add Docker Hub deployment #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Docker Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'docker/**' | |
| - '.github/workflows/docker-publish.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'docker/**' | |
| workflow_dispatch: # Allow manual trigger | |
| env: | |
| DOCKER_IMAGE: agentgatepay/tx-signing-service | |
| DOCKERFILE_PATH: docker/Dockerfile | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.DOCKER_IMAGE }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=sha,prefix={{branch}}- | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE_PATH }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64,linux/arm64 | |
| cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache | |
| cache-to: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache,mode=max | |
| build-args: | | |
| BUILD_DATE=${{ steps.meta.outputs.created }} | |
| VCS_REF=${{ github.sha }} | |
| - name: Image digest | |
| run: echo ${{ steps.meta.outputs.digest }} | |
| - name: Update Docker Hub Description | |
| if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| uses: peter-evans/dockerhub-description@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| repository: ${{ env.DOCKER_IMAGE }} | |
| short-description: "Secure transaction signing service for autonomous AI agent payments" | |
| readme-filepath: ./docker/README.md |