diff --git a/.github/workflows/CICDwithEC2.yml b/.github/workflows/CICDwithEC2.yml new file mode 100644 index 0000000..2a3c9d5 --- /dev/null +++ b/.github/workflows/CICDwithEC2.yml @@ -0,0 +1,37 @@ +name: CICD with EC2 + +on: + push: + branches: [main] + + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-22.04 + + if: github.ref == 'refs/heads/main' + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - run: yarn install --immutable + - run: yarn build + + - name: rsync deployments + uses: burnett01/rsync-deployments@6.0.0 + with: + switches: -avzr --delete --exclude=".env" + path: ./* + remote_path: /var/www/restaurant-service + remote_host: 52.76.71.215 + remote_user: ubuntu + remote_key: '${{ secrets.SSH_PRIVATE_KEY }}'