Merge branch 'develop' of https://github.com/bounswe/bounswe2023group… #47
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: Frontend CI/CD | |
on: | |
#workflow_dispatch: | |
push: | |
branches: [ develop ] | |
paths: | |
- 'app/frontend/**' | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
env: | |
working-directory: ./app/frontend | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Build Docker image | |
working-directory: ${{env.working-directory}} | |
run: | | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-frontend:${{ github.run_number }} . | |
- name: Login to Docker Hub | |
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
- name: Push Docker image | |
run: | | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-frontend:${{ github.run_number }} | |
# SSH and Deploy to Server | |
- name: Setup SSH Agent | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Deploy to Server | |
run: | | |
ssh -o StrictHostKeyChecking=no root@${{ secrets.SERVER_IP }} \ | |
"docker pull ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-frontend:${{ github.run_number }} && \ | |
docker stop gamelounge-frontend || true && \ | |
docker rm gamelounge-frontend || true && \ | |
docker run -d --name gamelounge-frontend -p 3000:3000 -e REACT_APP_API_URL=https://game-lounge.com:9090 ${{ secrets.DOCKERHUB_USERNAME }}/gamelounge-frontend:${{ github.run_number }}" | |