Create docker-image.yml
This commit is contained in:
parent
b7637184ca
commit
e2d0345aa6
|
|
@ -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
|
||||||
Loading…
Reference in New Issue