Skip to content

big fix shell

big fix shell #308

Workflow file for this run

name: Build and Deploy to Docker Hub
on:
push:
branches:
- auth_rbac
paths-ignore:
- '**.github/workflows/**' # Ignore changes to workflow files
workflow_dispatch: # Allows manual trigger for testing
jobs:
build-and-push:
runs-on: ubuntu-latest
if: contains(github.event.head_commit.message, '[deploy]') # Condition to check the commit message
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Read current version
id: read_version
run: |
VERSION=$(cat version.txt)
echo "Current version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Increment version
id: increment_version
run: |
NEW_VERSION=$(awk -F. '{print $1"."($2+1)}' version.txt)
echo "New version: $NEW_VERSION"
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo $NEW_VERSION > version.txt
- name: Build and push multi-architecture image
run: |
echo "Building and pushing multi-architecture image for linux/amd64 and linux/arm64..."
docker buildx build --platform linux/amd64,linux/arm64 \
-t ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:${{ env.NEW_VERSION }} \
-t ${{ secrets.DOCKER_HUB_USERNAME }}/mdv-frontend:latest \
--push .
- name: Commit and push new version
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add version.txt
git commit -m "Increment version to ${{ env.NEW_VERSION }} [skip ci]"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}