Create docker-image.yml

This commit is contained in:
JurTI-BR 2025-01-30 16:55:51 -03:00 committed by GitHub
parent b7637184ca
commit e2d0345aa6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 41 additions and 0 deletions

41
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: Docker CI/CD
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Build and Tag Docker Image
run: |
docker build -t link70/vendaweb:latest .
docker tag link70/vendaweb:latest link70/vendaweb:$(date +%Y%m%d%H%M)
- name: Push Docker Image to Docker Hub
run: |
docker push link70/vendaweb:latest
docker push link70/vendaweb:$(date +%Y%m%d%H%M)
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: SSH into Server and Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
docker pull link70/vendaweb:latest
docker stack deploy -c docker-compose.yml vendaweb