Skip to content

try 150

try 150 #174

Workflow file for this run

name: Build and Deploy Docker Image on Server
on:
push
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SERVER_USER: ${{ secrets.SERVER_USER }}
SERVER_HOST: ${{ secrets.SERVER_HOST }}
KNOWN_HOSTS: ${{ secrets.KNOWN_HOSTS }}
DIRECTORY: "${{ vars.DIRECTORY }}/${{ github.event.repository.name }}"
jobs:
build-and-deploy:
environment: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "latest"
- name: Create .env file
run: |
echo "${{ secrets.ENVS }}" > .env
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ env.SSH_PRIVATE_KEY }}
- name: Add server to known hosts
run: |
mkdir -p ~/.ssh
echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts

Check failure on line 42 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/deploy.yml

Invalid workflow file

You have an error in your yaml syntax on line 42
- name: Deploy on Server
run: |
ssh -t $SERVER_USER@$SERVER_HOST << EOF
# Prepare the directory
if [ -d "$DIRECTORY" ]; then
rm -rf $DIRECTORY
fi
mkdir -p $DIRECTORY
cd $DIRECTORY
eval `ssh-agent -s`
ssh-add /home/github/.ssh/keys/cloning/id_rsa
# echo "$SSH_PRIVATE_KEY" > ~/.ssh/keys/cloning/github_key
# chmod 600 ~/.ssh/keys/cloning/github_key
# echo "IdentityFile ~/.ssh/keys/cloning/github_key" >> ~/.ssh/config
# Clone the repository with submodules
git clone -b cicd https://github.com/${{ github.repository }} .
git submodule init
git submodule update
# Create .env file
echo "${{ secrets.ENVS }}" > .env
# Run deploy script
sh deploy.sh
EOF