File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Keep Backend Active
2+
3+ on :
4+ schedule :
5+ - cron : ' */45 * * * *' # Runs every 45 minutes
6+ workflow_dispatch :
7+
8+ jobs :
9+ ping-backend :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout repository
13+ uses : actions/checkout@v3
14+
15+ - name : Set up Node.js
16+ uses : actions/setup-node@v3
17+ with :
18+ node-version : 18
19+
20+ - name : Run ping script
21+ run : cd scripts && node ping.js ${{ secrets.BACKEND_URL }}
Original file line number Diff line number Diff line change 1+ const args = process . argv . slice ( 2 ) ;
2+
3+ if ( args . length < 1 ) {
4+ console . error ( "Usage: node ping.js <backend-url>" ) ;
5+ process . exit ( 1 ) ;
6+ }
7+
8+ const BACKEND_URL = args [ 0 ] ;
9+
10+ async function pingBackend ( ) {
11+ try {
12+ const response = await fetch ( BACKEND_URL , { method : "GET" } ) ;
13+ if ( response . ok ) {
14+ console . log ( "Ping successful at" , new Date ( ) . toLocaleTimeString ( ) ) ;
15+ } else {
16+ console . error ( "Ping failed with status:" , response . status ) ;
17+ }
18+ } catch ( error ) {
19+ console . error ( "Ping error:" , error ) ;
20+ }
21+ }
22+
23+ // Function call
24+ pingBackend ( ) ;
You can’t perform that action at this time.
0 commit comments