From 0a68878a11c9dd3756a1e11a08ecf9225ba30010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 29 Sep 2022 18:22:02 -0300 Subject: [PATCH 1/7] Update mocked user to authenticate --- src/context/auth.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/context/auth.js b/src/context/auth.js index fc3f4b2..655b8d1 100644 --- a/src/context/auth.js +++ b/src/context/auth.js @@ -22,8 +22,7 @@ function AuthProvider(props) { const register = data => { setState({ ...state, status: 'pending' }); - let shouldFail = - data.email !== 'leo@gmail.com' && data.password !== '#leo1234'; + let shouldFail = false; return registerUser(data, shouldFail).then(data => { if (shouldFail) { @@ -36,7 +35,7 @@ function AuthProvider(props) { const login = (email, password) => { setState({ ...state, status: 'pending' }); - let shouldFail = email !== 'leo@gmail.com' && password !== '#leo1234'; + let shouldFail = email !== 'teste@teste.com' || password !== '#teste1234'; return getUser(shouldFail).then(data => { if (shouldFail) { From 78e78006012b4bce4b7d4801013fc16c9c298f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Tue, 1 Nov 2022 11:25:15 -0300 Subject: [PATCH 2/7] Improve pipeline by removing steps from packagejson --- .github/workflows/deploy-dev.yml | 7 ++----- .github/workflows/deploy-prod.yml | 7 ++----- package.json | 4 +--- scripts/deploy.sh | 12 ++++++++++++ 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 scripts/deploy.sh 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 From e09397e3e8daab5209a165dc342e43a0ae7337b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Tue, 1 Nov 2022 11:29:42 -0300 Subject: [PATCH 3/7] Remove wrong step name --- .github/workflows/deploy-dev.yml | 1 - .github/workflows/deploy-prod.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 786dc8b..ff5f7d6 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -21,5 +21,4 @@ jobs: cache: 'npm' - run: npm install - run: npm run build: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 3c43379..952eefd 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -21,5 +21,4 @@ jobs: cache: 'npm' - run: npm install - run: npm run build:prod - - name: Copying build files to server - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh prod From 07756f89947cc9f7f95257eb2f5b7c057233932f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Tue, 1 Nov 2022 11:37:01 -0300 Subject: [PATCH 4/7] Fix line break on deploy script --- scripts/deploy.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 7f4fd31..d61b7f0 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -3,10 +3,5 @@ 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 && +echo -e "Host ifsalas\n\tUser ifsalas\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_rsa_ifsalas\n\tStrictHostKeyChecking No" >> ~/.ssh/config && rsync -avz --progress build/ ifsalas:/home/ifsalas/web/$1 --delete From 1285693ac822ebc44ef31282d9cc04eec60eba1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Tue, 1 Nov 2022 11:41:53 -0300 Subject: [PATCH 5/7] Pass SSH_KEY as parameter --- .github/workflows/deploy-dev.yml | 2 +- .github/workflows/deploy-prod.yml | 2 +- scripts/deploy.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index ff5f7d6..2d61d35 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -21,4 +21,4 @@ jobs: cache: 'npm' - run: npm install - run: npm run build:dev - - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh dev + - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh $SSH_KEY dev diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 952eefd..6aaf6c1 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -21,4 +21,4 @@ jobs: cache: 'npm' - run: npm install - run: npm run build:prod - - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh prod + - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh $SSH_KEY prod diff --git a/scripts/deploy.sh b/scripts/deploy.sh index d61b7f0..6293116 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,7 +1,7 @@ #!/bin/sh mkdir ~/.ssh && -echo "$SSH_KEY" >> ~/.ssh/id_rsa_ifsalas && +echo "$1" >> ~/.ssh/id_rsa_ifsalas && chmod 400 ~/.ssh/id_rsa_ifsalas && echo -e "Host ifsalas\n\tUser ifsalas\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_rsa_ifsalas\n\tStrictHostKeyChecking No" >> ~/.ssh/config && -rsync -avz --progress build/ ifsalas:/home/ifsalas/web/$1 --delete +rsync -avz --progress build/ ifsalas:/home/ifsalas/web/$2 --delete From ab1dfde64d6b70b9a9fbca1f816eb321a7d0bdc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Tue, 1 Nov 2022 11:50:07 -0300 Subject: [PATCH 6/7] Update pipeline --- .github/workflows/deploy-dev.yml | 6 +++++- .github/workflows/deploy-prod.yml | 6 +++++- scripts/deploy.sh | 7 ------- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 scripts/deploy.sh diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 2d61d35..6b3cc90 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -21,4 +21,8 @@ jobs: cache: 'npm' - run: npm install - run: npm run build:dev - - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh $SSH_KEY dev + - 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: rsync -avz --progress build/ ifsalas:/home/ifsalas/web/dev --delete diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 6aaf6c1..cde31be 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -21,4 +21,8 @@ jobs: cache: 'npm' - run: npm install - run: npm run build:prod - - run: sh ${GITHUB_WORKSPACE}/scripts/deploy.sh $SSH_KEY prod + - 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: rsync -avz --progress build/ ifsalas:/home/ifsalas/web/prod --delete diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100644 index 6293116..0000000 --- a/scripts/deploy.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -mkdir ~/.ssh && -echo "$1" >> ~/.ssh/id_rsa_ifsalas && -chmod 400 ~/.ssh/id_rsa_ifsalas && -echo -e "Host ifsalas\n\tUser ifsalas\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_rsa_ifsalas\n\tStrictHostKeyChecking No" >> ~/.ssh/config && -rsync -avz --progress build/ ifsalas:/home/ifsalas/web/$2 --delete From 15a0af96c7bba805de6eb0284ef117a04f9d8486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Tue, 1 Nov 2022 11:54:00 -0300 Subject: [PATCH 7/7] Remove && --- .github/workflows/deploy-dev.yml | 2 +- .github/workflows/deploy-prod.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 6b3cc90..496257c 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -24,5 +24,5 @@ jobs: - 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: 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: rsync -avz --progress build/ ifsalas:/home/ifsalas/web/dev --delete diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index cde31be..403abb7 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -24,5 +24,5 @@ jobs: - 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: 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: rsync -avz --progress build/ ifsalas:/home/ifsalas/web/prod --delete