diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 0e2f590..786dc8b 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -19,10 +19,7 @@ jobs: with: node-version: 16 cache: 'npm' - - run: mkdir ~/.ssh - - run: 'echo "$SSH_KEY" >> ~/.ssh/id_rsa_ifsalas' - - run: chmod 400 ~/.ssh/id_rsa_ifsalas - - run: echo -e "Host ifsalas\n\tUser ifsalas\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_rsa_ifsalas\n\tStrictHostKeyChecking No" >> ~/.ssh/config - run: npm install - run: npm run build:dev - - run: npm run deploy:dev + - name: Copying build files to server + - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh dev diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 179ee2b..3c43379 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -19,10 +19,7 @@ jobs: with: node-version: 16 cache: 'npm' - - run: mkdir ~/.ssh - - run: 'echo "$SSH_KEY" >> ~/.ssh/id_rsa_ifsalas' - - run: chmod 400 ~/.ssh/id_rsa_ifsalas - - run: echo -e "Host ifsalas\n\tUser ifsalas\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_rsa_ifsalas\n\tStrictHostKeyChecking No" >> ~/.ssh/config - run: npm install - run: npm run build:prod - - run: npm run deploy:prod + - name: Copying build files to server + - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh prod diff --git a/package.json b/package.json index bf5f7b6..12c55ad 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,7 @@ "start:dev": "env-cmd -f .env.dev npm run start", "start:prod": "env-cmd -f .env.prod npm run start ", "build:dev": "env-cmd -f .env.dev npm run build", - "build:prod": "env-cmd -f .env.prod npm run build", - "deploy:prod": "rsync -avz --progress build/ ifsalas:/home/ifsalas/web/prod --delete", - "deploy:dev": "rsync -avz --progress build/ ifsalas:/home/ifsalas/web/dev --delete" + "build:prod": "env-cmd -f .env.prod npm run build" }, "eslintConfig": { "extends": [ diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..7f4fd31 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +mkdir ~/.ssh && +echo "$SSH_KEY" >> ~/.ssh/id_rsa_ifsalas && +chmod 400 ~/.ssh/id_rsa_ifsalas && +echo -e " + Host ifsalas\n\t \ + User ifsalas\n\t \ + Hostname 45.76.5.44\n\t \ + IdentityFile ~/.ssh/id_rsa_ifsalas\n\t \ + StrictHostKeyChecking No" >> ~/.ssh/config && +rsync -avz --progress build/ ifsalas:/home/ifsalas/web/$1 --delete