Skip to content

Merge pull request #1110 from peer-42seoul/1.0.7/C-ALARM/1092 #1122

Merge pull request #1110 from peer-42seoul/1.0.7/C-ALARM/1092

Merge pull request #1110 from peer-42seoul/1.0.7/C-ALARM/1092 #1122

Workflow file for this run

name: Test server CI/CD
on:
push:
branches: ['develop', 'release-**']
pull_request:
branches: ['develop', 'release-**']
types: ['opened', 'reopened', 'synchronize', 'closed']
jobs:
CI:
name: Test CI!! πŸ˜ƒ
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout 🏁
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Check current directory
run: |
echo "Current directory:"
pwd
echo "Directory content:"
ls -la
- name: Change to project dic
run: cd /home/runner/work/Peer-Frontend/Peer-Frontend
- name: Install packages
run: npm i /home/runner/work/Peer-Frontend/Peer-Frontend
- name: Prettier
working-directory: /home/runner/work/Peer-Frontend/Peer-Frontend
run: npm run format
- name: Lint
working-directory: /home/runner/work/Peer-Frontend/Peer-Frontend
run: npm run lint
- name: Build Test
working-directory: /home/runner/work/Peer-Frontend/Peer-Frontend
run: npm run build
CD:
name: Test CD πŸ‘»
# if: github.ref == 'refs/heads/develop' && (github.event.pull_request.merged == true || github.event_name == 'push')
if: (github.ref == 'refs/heads/develop' || contains(github.ref, 'release')) && (github.event.pull_request.merged == true || github.event_name == 'push')
runs-on: ubuntu-latest
needs: CI
steps:
- name: Checkout 🏁
uses: actions/checkout@v2
- name: Build and push Docker image
run: |
touch /home/runner/work/Peer-Frontend/Peer-Frontend/.env.production
echo "${{ secrets.ENV_FILE }}" >> /home/runner/work/Peer-Frontend/Peer-Frontend/.env.production
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }}
- name: Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_TEST_HOST }}
port: 22
username: ${{ secrets.DEV_TEST_USERNAME }}
password: ${{ secrets.DEV_TEST_KEY }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }}
docker rm -f ${{ secrets.DOCKER_DEV_TEST_IMAGE }}
docker run --name=${{ secrets.DOCKER_DEV_TEST_IMAGE }} --network ${{ secrets.TEST_NETWORK }} -d -p 3000:3000 --ip ${{ secrets.TEST_PRIVATE_IP }} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_DEV_TEST_IMAGE }}
docker container prune -f
docker image prune -f