Cloud check in action #2220
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: Cloud check in action | |
| on: | |
| push: | |
| branches: | |
| - main | |
| watch: | |
| types: started | |
| workflow_dispatch: | |
| schedule: | |
| - cron: 35 2 * * * | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| environment: user | |
| steps: | |
| - name: 🔀 random delay 0-300 seconds | |
| run: sleep $((RANDOM % 301)) | |
| - name: 🔌 Check out code | |
| uses: actions/checkout@main | |
| - name: 🔨 Setup Node.js environment | |
| uses: actions/setup-node@main | |
| with: | |
| node-version: 18 | |
| cache: npm | |
| - name: 👾 Check if Debug is true | |
| if: vars.debug == '1' | |
| run: | | |
| echo "CLOUD189_VERBOSE=1" >> $GITHUB_ENV | |
| - name: 📹 Restore cached Cookie | |
| id: cache-cookie-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .token | |
| key: ${{ runner.os }}-cache-token | |
| restore-keys: ${{ runner.os }}-cache-token- | |
| - name: 🔧 Init secrets | |
| uses: shine1594/secrets-to-env-action@master | |
| with: | |
| secrets: ${{ toJSON(secrets) }} | |
| secrets_env: production | |
| prefix_prod: "" | |
| file_name_prod: .env | |
| - name: 📡 Init dependencies | |
| run: npm install | |
| - name: 🚀 Run | |
| uses: nick-fields/retry@master | |
| with: | |
| timeout_minutes: 30 | |
| max_attempts: 3 | |
| command: npm start | |
| - name: 📹 Save cached Cookie | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: .token | |
| key: ${{ runner.os }}-cache-token-${{ hashFiles('.token/*.json') }} | |
| - name: 🚗 Keep Running | |
| if: github.event_name == 'schedule' | |
| run: | | |
| git config --local user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" | |
| git config --local user.name "${{ github.actor }}" | |
| git remote set-url origin https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }} | |
| git pull --rebase --autostash | |
| git commit --allow-empty -m "Keep Running..." | |
| git push | |
| - name: 🎉 Delete old workflow run | |
| uses: Mattraks/delete-workflow-runs@main | |
| with: | |
| token: ${{ github.token }} | |
| repository: ${{ github.repository }} | |
| retain_days: 0 | |
| keep_minimum_runs: 50 |