-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add github actions for build and publish to docker hub
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
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
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 |