update path #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build on DockerHub and Deploy to OVH Cloud | |
on: | |
push: | |
branches: | |
- main | |
env: | |
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./ | |
push: true | |
dockerfile: ./Dockerfile | |
tags: nguyenhau2003/mindustry-gpt:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKERHUB_USERNAME }} | |
password: ${{ env.DOCKERHUB_TOKEN }} | |
- name: copy files to target server via scp | |
uses: appleboy/scp-action@v0.1.3 | |
with: | |
host: ${{ secrets.OVH_CLOUD_IP }} | |
username: ${{ secrets.OVH_CLOUD_USERNAME }} | |
password: ${{ secrets.OVH_CLOUD_PASSWORD }} | |
source: "./docker-compose.yml" | |
target: "~/.deploy/${{github.event.repository.name }}/" | |
- name: Pull image | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.OVH_CLOUD_IP }} | |
username: ${{ secrets.OVH_CLOUD_USERNAME }} | |
password: ${{ secrets.OVH_CLOUD_PASSWORD }} | |
context: ./ | |
script: | | |
sudo docker login --username nguyenhau2003 -p ${{ env.DOCKERHUB_TOKEN }} | |
cd ~/.deploy/${{github.event.repository.name}} | |
sudo docker compose -f ./docker-compose.yml pull | |
sudo docker rm -f mindustry-gpt | |
sudo docker compose -f ./docker-compose.yml -p mindustry-gpt up -d |