Skip to content

Update main.yml

Update main.yml #55

Workflow file for this run

name: build-deploy
on:
push:
branches: [ "dev", "main" ]
pull_request:
branches: [ "dev", "main" ]
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build Docker image
run: docker build . -f ./Dockerfile -t fivlao/sound:latest-dev
- name: Save Docker image as tar file
run: |
docker save -o fivlao-sound.tar fivlao/sound:latest-dev
chmod 664 fivlao-sound.tar
touch file.txt
pwd
ls
- name: Transfer Docker image to remote server
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: "fivlao-sound.tar"
target: "/home/ubuntu"
- name: Run new image version
uses: appleboy/ssh-action@master
with:
key: ${{ secrets.EC2_PRIVATE_KEY }}
username: ${{ secrets.EC2_USERNAME }}
host: ${{ secrets.EC2_HOST }}
script: |
sudo docker load -i "/home/ubuntu/fivlao-sound.tar"
sudo docker stop prometei-rest-api || true
sudo docker rm prometei-rest-api || true
sudo docker run -d --name=prometei-rest-api -p 80:80 fivlao/sound:latest-dev