File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,18 +34,30 @@ jobs:
3434 push : true
3535 tags : cornellappdev/eatery-prod:${{ steps.vars.outputs.sha_short }}
3636
37- - name : Remote SSH and Deploy
38- uses : appleboy/ssh-action@v1.0.3
37+ - name : Deploy with Native SSH
3938 env :
39+ PRIVATE_KEY : ${{ secrets.PROD_SERVER_KEY }}
40+ HOST : ${{ secrets.PROD_SERVER_HOST }}
41+ USER : ${{ secrets.SERVER_USERNAME }}
4042 IMAGE_TAG : ${{ steps.vars.outputs.sha_short }}
41- with :
42- host : ${{ secrets.PROD_SERVER_HOST }}
43- username : ${{ secrets.SERVER_USERNAME }}
44- key : ${{ secrets.PROD_SERVER_KEY }}
45- script : |
46- export IMAGE_TAG=${{ steps.vars.outputs.sha_short }}
43+ run : |
44+ # Setup SSH directory
45+ mkdir -p ~/.ssh
46+ chmod 700 ~/.ssh
47+
48+ # Save the Private Key to a file using the env var
49+ echo "$PRIVATE_KEY" > ~/.ssh/id_rsa
50+ chmod 600 ~/.ssh/id_rsa
51+
52+ # Add the server to known_hosts to avoid prompt
53+ ssh-keyscan -H "$HOST" >> ~/.ssh/known_hosts
54+
55+ # Run the remote commands
56+ ssh -i ~/.ssh/id_rsa "$USER@$HOST" "
57+ export IMAGE_TAG=$IMAGE_TAG
4758 cd docker-compose
4859 docker stack rm thestack
49- sleep 20s
60+ sleep 20
5061 docker stack deploy -c docker-compose.yml thestack
51- yes | docker system prune -a
62+ docker system prune -af
63+ "
You can’t perform that action at this time.
0 commit comments