diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..a876b8f --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -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 \ No newline at end of file