Skip to content

Added automatic Tag and Release publication #3

Added automatic Tag and Release publication

Added automatic Tag and Release publication #3

name: Build, Publish Docker Image, and Create Release
on:
push:
branches:
- main # Trigger workflow on pushes to the main branch
workflow_dispatch: # Allow manual triggering of the workflow
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Read version from version.txt
id: read_version
run: |
version=$(cat version.txt)
echo "version=$version" >> $GITHUB_ENV
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and tag Docker image
run: |
docker image build -t jwaresolutions/big-data-cluster:$version .
docker tag jwaresolutions/big-data-cluster:$version jwaresolutions/big-data-cluster:latest
- name: Push Docker image
run: |
docker image push jwaresolutions/big-data-cluster:$version
docker image push jwaresolutions/big-data-cluster:latest
- name: Create Git tag and push
id: create_tag
run: |
git tag -a "v$version" -m "Release v$version"
git push origin "v$version"
- name: Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: "v${{ env.version }}"
release_name: "Release v${{ env.version }}"
body: |
This release corresponds to Docker image v${{ env.version }}.
The image has been published to Docker Hub.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}