Skip to content

refactor(deploy): fix versioning Dockerhub #77

refactor(deploy): fix versioning Dockerhub

refactor(deploy): fix versioning Dockerhub #77

Workflow file for this run

# GitHub Actions Workflow: Build and Deploy to VPS
# - Triggers on push to the master branch.
# - Builds and pushes a Docker image to Docker Hub.
# - Deploys the Docker Compose file to a remote VPS.
# - Starts the application on the VPS.
name: Build and Deploy to VPS (test)
on:
push:
branches:
- test-deploy
jobs:
docker:
runs-on: ubuntu-latest
environment: gzgestaoprod
steps:
# Checkout do código
- name: Checkout
uses: actions/checkout@v4
# Ler a versão do arquivo pom.xml ignorando a versão do parent
- name: Extract version from pom.xml
id: extract_version
run: |
VERSION=$(grep -m1 -oP '(?<=<version>)[^<]+' pom.xml | tail -1)
echo "VERSION=$VERSION" >> $GITHUB_ENV
# Setup do QEMU para multi-plataforma
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Setup do Docker Buildx para builds multi-plataforma
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Login no Docker Hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build e Push da imagem Docker para o Docker Hub com tags apropriadas
- name: Build and push to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/gzgestao:latest
${{ secrets.DOCKERHUB_USERNAME }}/gzgestao:${{ env.VERSION }}