Skip to content

add github actions for build and publish to docker hub #1

add github actions for build and publish to docker hub

add github actions for build and publish to docker hub #1

Workflow file for this run

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