Skip to content

Update docker-image.yml #2

Update docker-image.yml

Update docker-image.yml #2

Workflow file for this run

name: Deploy to Server
on:
push:
branches:
- origin
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
# - name: Set up SSH
# uses: webfactory/ssh-agent@v0.5.3
# with:
# ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
# - name: Update packages
# run: |
# sudo apt-get update -y
# sudo apt-get upgrade -y
- name: Remove conflicting packages
run: |
sudo apt-get remove -y containerd
sudo apt-get clean
sudo apt-get update
sudo apt-get autoremove -y
sudo apt-get install -y containerd.io
- name: Build and push Docker image
run: |
docker build -t docker-test-angular .
docker login -u 10449 -p ${{ secrets.DOCKERHUB_TOKEN }}
docker tag docker-test 10449/docker-test-angular
docker push 10449/docker-test-angular
- name: Disable strict host key checking
run: echo "StrictHostKeyChecking no" >> ~/.ssh/config
- name: SSH into server and deploy
run: |
ssh root@61.97.102.90 'docker pull 10449/docker-test-angular && docker run -d -p 5200:5200 10449/docker-test-angular'
# ssh root@95.130.227.6 "docker pull 10449/docker-test && docker-compose up -d"