Skip to content

Commit

Permalink
feat: Release Docker image on build
Browse files Browse the repository at this point in the history
  • Loading branch information
binarybaron authored Jul 16, 2024
1 parent d55c6e8 commit eab4b00
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion .github/workflows/build-release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [created]

env:
DOCKER_IMAGE_NAME: unstoppableswap/asb

jobs:
build_binaries:
name: Build
Expand Down Expand Up @@ -82,7 +85,7 @@ jobs:
run: target/${{ matrix.target }}/release/${{ matrix.bin }} --help

- id: create-archive-name
shell: python # Use python to have a prettier name for the archive on Windows.
shell: python
run: |
import platform
os_info = platform.uname()
Expand Down Expand Up @@ -122,3 +125,32 @@ jobs:
asset_path: ./${{ steps.create-archive-name.outputs.archive }}
asset_name: ${{ steps.create-archive-name.outputs.archive }}
asset_content_type: application/gzip

build_and_push_docker:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: build_binaries
steps:
- name: Checkout code
uses: actions/checkout@v4.1.7
with:
ref: ${{ github.event.release.target_commitish }}

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

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

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.DOCKER_IMAGE_NAME }}:latest
${{ env.DOCKER_IMAGE_NAME }}:${{ github.event.release.tag_name }}

0 comments on commit eab4b00

Please sign in to comment.