rbenv to path? #29
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 | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# - name: Checkout Code | |
# uses: actions/checkout@v2 | |
# - name: Set Up SSH Agent | |
# env: | |
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} # Ensure you have added the SSH private key as a secret | |
# run: | | |
# echo "$SSH_PRIVATE_KEY" > private_key | |
# chmod 600 private_key | |
# eval "$(ssh-agent -s)" | |
# ssh-add private_key | |
- name: Execute Commands on Remote Server | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.PUBLIC_KEY }}" > ~/.ssh/id_rsa.pub | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa.pub | |
chmod 600 ~/.ssh/id_rsa | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
ssh -p ${{ secrets.REMOTE_PORT }} -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} << 'EOF' | |
cd /home/shensquared/gradML | |
echo "Running on main branch" | |
git pull origin main | |
bundle exec jekyll build | |
EOF | |
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then | |
ssh -p ${{ secrets.REMOTE_PORT }} -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} << 'EOF' | |
cd /home/shensquared/gradML_dev # Replace with the relevant folder path | |
echo "Running on dev branch" | |
git pull origin dev | |
export PATH="/home/shensquared/.rbenv/bin:$PATH" | |
eval "$(rbenv init -)" | |
echo "Current Ruby version:" | |
ruby -v | |
echo "Bundler version:" | |
bundle -v | |
bundle install | |
bundle exec jekyll build --config _config.yml,_config_dev.yml | |
EOF | |
fi | |