Merge pull request #48 from bdsumon4u/dev #194
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: [master] | |
pull_request: | |
branches: [master] | |
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 Servers | |
run: | | |
echo "Deploying to cyber32n" | |
ssh -vvv -o "IdentitiesOnly=yes" -i /tmp/private_key -p ${{ secrets.PORT }} cyber32n@${{ secrets.HOST }} "cd ecom1.cyber32.net && ./server_deploy.sh" || echo -e "\e[31mError deploying to cyber32n\e[0m" # Red color | |
for username in $(echo "${{ vars.USERNAMES }}" | tr ',' '\n'); do | |
echo "Deploying to $username" | |
ssh -vvv -o "IdentitiesOnly=yes" -i /tmp/private_key -p ${{ secrets.PORT }} $username@${{ secrets.HOST }} "${{ secrets.SCRIPT }}" || echo -e "\e[31mError deploying to $username\e[0m" # Red color | |
done | |
- name: Cleanup temporary files | |
run: rm /tmp/private_key |