add github actions for build and publish to docker hub #1
Workflow file for this run
This file contains 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: 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 |