Skip to content

Update docker-image.yml #3

Update docker-image.yml

Update docker-image.yml #3

Workflow file for this run

name: Build and Push Docker Image with Version from version.txt
on:
push:
branches:
- docker
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# Read version from version.txt and add 'v' prefix
- name: Get version from version.txt
id: get_version
run: |
VERSION=$(cat version.txt)
VERSION="v$VERSION" # Add 'v' prefix to the version
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Log in to Docker Hub (or GHCR)
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build and push Docker image using version with 'v' prefix
- name: Build and push Docker image
run: |
docker build -t your-dockerhub-username/your-image-name:${{ env.VERSION }} .
docker push your-dockerhub-username/your-image-name:${{ env.VERSION }}