syntax error #4
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: Deploy to EC2 | |
on: | |
push: | |
branches: | |
- master # Replace with your branch name | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Configure SSH | |
env: | |
EC2_PRIVATE_KEY: ${{ secrets.EC2_PRIVATE_KEY }} | |
run: | | |
mkdir -p ~/.ssh | |
echo "$EC2_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 400 ~/.ssh/id_rsa | |
- name: Clone repository on EC2 | |
env: | |
EC2_HOST: ${{ secrets.EC2_HOST }} | |
EC2_USER: ${{ secrets.EC2_USER }} | |
run: | | |
ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST ' | |
git clone ${{ github.event.repository.clone_url }} | |
' | |
- name: Create .env file | |
env: | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
DEPLOYMENT: ${{ secrets.DEPLOYMENT }} | |
run: | | |
echo "ACCESS_TOKEN=$ACCESS_TOKEN" > .env | |
echo "DEPLOYMENT_ENV=$DEPLOYMENT_ENV" >> .env | |
- name: Upload .env file to EC2 | |
env: | |
EC2_HOST: ${{ secrets.EC2_HOST }} | |
EC2_USER: ${{ secrets.EC2_USER }} | |
run: | | |
scp -o StrictHostKeyChecking=no .env $EC2_USER@$EC2_HOST:/rashan/.env | |
- name: Run bot | |
run: | | |
sudo -i | |
chmod +x install.sh | |
python3 bot.py | |