add environment variable in index and frontend_cd file (#140) #65
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: React CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 18 | |
- name: Set environment variable | |
run: echo "NODE_ENV=development" >> $GITHUB_ENV | |
- name: Display environment variable | |
run: echo "NODE_ENV=${NODE_ENV}" | |
- name: Move to workspace | |
run: | | |
mv packages/frontend $GITHUB_WORKSPACE | |
- name: Deploy to Server | |
uses: easingthemes/ssh-deploy@main | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} | |
REMOTE_HOST: ${{ secrets.HOST }} | |
REMOTE_USER: ${{ secrets.USERNAME }} | |
TARGET: ${{ secrets.TARGET_DIR }} | |
- name: Executing remote ssh commands using ssh key | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
port: ${{ secrets.PORT }} | |
script: | | |
cd ~/citadels/frontend | |
sudo docker stop react-container | |
sudo docker rm react-container | |
sudo docker rmi react-image | |
sudo docker build --no-cache -t react-image . | |
sudo docker run --name react-container -d -p 3001:3001 react-image |