Skip to content

Commit

Permalink
add github actions for build and publish to docker hub
Browse files Browse the repository at this point in the history
  • Loading branch information
100nandoo committed Nov 1, 2024
1 parent 24cede7 commit cf77c46
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Docker Image on Tag

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Extract version tag
id: vars
run: |
TAG="${GITHUB_REF##*/}" # Get tag from GITHUB_REF
echo "tag=${TAG}" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build -t 100nandoo/gobot:${{ env.tag }} .
docker tag 100nandoo/gobot:${{ env.tag }} 100nandoo/gobot:latest
- name: Push Docker image with tag
run: |
docker push 100nandoo/gobot:${{ env.tag }}
docker push 100nandoo/gobot:latest

0 comments on commit cf77c46

Please sign in to comment.