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: Continuous Deployment | |
on: | |
push: | |
branches: [dev] | |
pull_request: | |
branches: [dev] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install SSH client | |
run: sudo apt-get install -y openssh-client | |
- name: Create SSH directory and known_hosts file | |
run: mkdir -p ~/.ssh && touch ~/.ssh/known_hosts | |
- name: Add SSH known hosts | |
run: ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts | |
- name: Store private key in a temporary file | |
run: echo "${{ secrets.KEY }}" > /tmp/private_key && chmod 600 /tmp/private_key | |
- name: Deploy to Server | |
run: | | |
echo "Deploying to cyber32n" | |
ssh -vvv -o "IdentitiesOnly=yes" -i /tmp/private_key -p ${{ secrets.PORT }} cyber32n@${{ secrets.HOST }} "cd tcom1.cyber32.net && ./server_deploy.sh --dev" || echo -e "\e[31mError deploying to cyber32n\e[0m" # Red color | |
- name: Cleanup temporary files | |
run: rm /tmp/private_key |