Merge pull request #20 from AuthEceSoftEng:thanos #203
This file contains hidden or 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: ci | |
| on: push | |
| jobs: | |
| deploy: | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up NodeJS environment | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 16 | |
| - name: Cache node modules | |
| id: cache-npm | |
| uses: actions/cache@v3 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| - name: Install package dependencies | |
| run: npm install | |
| - name: Create build | |
| env: | |
| CI: false | |
| REACT_APP_MAIN_SERVER_URL: ${{ secrets.REACT_APP_MAIN_SERVER_URL }} | |
| REACT_APP_WEBSOCKET_URL: ${{ secrets.REACT_APP_WEBSOCKET_URL }} | |
| REACT_APP_SENTRY_ENVIRONMENT: ${{ secrets.REACT_APP_SENTRY_ENVIRONMENT }} | |
| REACT_APP_SENTRY_DSN: ${{ secrets.REACT_APP_SENTRY_DSN }} | |
| REACT_APP_GOOGLE_CLIENT_ID: ${{ secrets.REACT_APP_GOOGLE_CLIENT_ID }} | |
| run: npm run build | |
| - name: rsync deployments | |
| uses: burnett01/[email protected] | |
| with: | |
| switches: -ahv --no-o --no-g --progress --delete --exclude=".git" --exclude="node_modules" --exclude=".env" | |
| remote_path: ~/ecoready-dashboard-frontend | |
| remote_host: ${{ secrets.SSH_HOST }} | |
| remote_port: ${{ secrets.SSH_PORT }} | |
| remote_user: ${{ secrets.SSH_USERNAME }} | |
| remote_key: ${{ secrets.SSH_KEY }} | |
| remote_key_pass: ${{ secrets.SSH_PASSWORD }} | |
| - uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USERNAME }} | |
| key: ${{ secrets.SSH_KEY }} | |
| passphrase: ${{ secrets.SSH_PASSWORD }} | |
| port: ${{ secrets.SSH_PORT }} | |
| script: | | |
| bash -ci 'pm2 restart client' | |
| deploy-staging: | |
| if: github.ref == 'refs/heads/staging' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up NodeJS environment | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 16 | |
| - name: Cache node modules | |
| id: cache-npm | |
| uses: actions/cache@v3 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| - name: Install package dependencies | |
| run: npm install | |
| - name: Create build | |
| env: | |
| CI: false | |
| REACT_APP_MAIN_SERVER_URL: ${{ secrets.REACT_APP_MAIN_SERVER_URL_STAGING }} | |
| REACT_APP_WEBSOCKET_URL: ${{ secrets.REACT_APP_WEBSOCKET_URL }} | |
| REACT_APP_SENTRY_ENVIRONMENT: ${{ secrets.REACT_APP_SENTRY_ENVIRONMENT_STAGING }} | |
| REACT_APP_SENTRY_DSN: ${{ secrets.REACT_APP_SENTRY_DSN }} | |
| REACT_APP_GOOGLE_CLIENT_ID: ${{ secrets.REACT_APP_GOOGLE_CLIENT_ID }} | |
| run: npm run build | |
| - name: rsync deployments | |
| uses: burnett01/[email protected] | |
| with: | |
| switches: -ahv --no-o --no-g --progress --delete --exclude=".git" --exclude="node_modules" --exclude=".env" | |
| remote_path: ~/ecoready-dashboard-frontend | |
| remote_host: ${{ secrets.SSH_STAGING_HOST }} | |
| remote_port: ${{ secrets.SSH_STAGING_PORT }} | |
| remote_user: ${{ secrets.SSH_STAGING_USERNAME }} | |
| remote_key: ${{ secrets.SSH_STAGING_KEY }} | |
| - uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_STAGING_HOST }} | |
| username: ${{ secrets.SSH_STAGING_USERNAME }} | |
| key: ${{ secrets.SSH_STAGING_KEY }} | |
| port: ${{ secrets.SSH_STAGING_PORT }} | |
| script: | | |
| bash -ci 'pm2 restart client' |