An automated system for managing 10bis credit loading and token refresh operations. Choose from three deployment options: GitHub Actions (cloud-based, no server required), Linux Server (traditional cron-based), or Docker (containerized testing).
- Automatic Token Refresh: Refreshes authentication tokens every 10 minutes
- Scheduled Credit Loading: Loads 10bis credit daily at 10 AM (excluding weekends)
- Microsoft Teams Notifications: Real-time notifications for success/failure with amount and timestamp
- Robust Error Handling: Comprehensive logging and retry mechanisms
- Secure Token Management: Automatic token updates and encrypted storage
- Weekend Detection: Automatically skips credit loading on Friday and Saturday
- Multiple Deployment Options: GitHub Actions, Linux Server, or Docker
- Zero Maintenance: GitHub Actions option requires no server maintenance
This system is designed for GitHub Actions deployment
β Advantages:
- No server required - runs in GitHub's cloud
- Automatic token updates stored securely in GitHub secrets
- Built-in logging and monitoring
- Free for most usage (2,000 minutes/month)
- Zero maintenance and security updates
- Microsoft Teams notifications
β Requirements:
- GitHub repository (free)
- GitHub Personal Access Token
π Setup Guide: GITHUB-ACTIONS-SETUP.md
# 1. Push your code to GitHub
git init
git add .
git commit -m "Initial commit"
git push origin main
# 2. Set up GitHub secrets (see GITHUB-ACTIONS-SETUP.md)
# 3. Update tokens when needed:
npm run update-github-secrets
# 4. The automation starts running automatically!git clone <repository-url> 10bis-automation
cd 10bis-automationnpm installFollow the GITHUB-ACTIONS-SETUP.md guide to configure:
ACCESS_TOKENREFRESH_TOKENAMOUNTMONEYCARD_IDTEAMS_WEBHOOK_URL(optional)PERSONAL_ACCESS_TOKEN
# Update GitHub repository secrets with fresh tokens
npm run update-github-secrets
# Test Teams notifications
npm run test-teams-connectionπ Teams Setup Guide: TEAMS-SETUP.md
which node
# Example output: /usr/bin/nodepwd
# Example output: /home/user/10bis-automationcrontab -eCopy the following lines to your crontab, replacing the paths with your actual paths:
# Token Refresh - Every 10 minutes
*/10 * * * * /usr/bin/node /home/user/10bis-automation/refresh-token.js >> /home/user/10bis-automation/logs/cron.log 2>&1
# Credit Loading - Daily at 10 AM (excluding Friday and Saturday)
0 10 * * 0,1,2,3,4 /usr/bin/node /home/user/10bis-automation/load-credit.js >> /home/user/10bis-automation/logs/cron.log 2>&1crontab -l10bis-automation/
βββ package.json # Node.js project configuration
βββ config.json # Authentication tokens and settings (local dev)
βββ README.md # Main documentation
βββ GITHUB-ACTIONS-SETUP.md # GitHub Actions deployment guide
βββ DEPLOYMENT.md # Linux server deployment guide
βββ DOCKER-TESTING.md # Docker testing guide
βββ TEAMS-SETUP.md # Microsoft Teams notifications setup guide
βββ TOKEN-TROUBLESHOOTING.md # Token refresh troubleshooting guide
βββ .github/
β βββ workflows/
β βββ 10bis-automation.yml # GitHub Actions workflow
βββ github-actions-utils.js # GitHub Actions compatible utilities
βββ github-refresh-token.js # Token refresh for GitHub Actions
βββ github-load-credit.js # Credit loading for GitHub Actions
βββ utils.js # Utility functions (server deployment)
βββ refresh-token.js # Token refresh script (server deployment)
βββ load-credit.js # Credit loading script (server deployment)
βββ teams-notifier.js # Teams notification utility (server deployment)
βββ github-teams-notifier.js # Teams notification utility (GitHub Actions)
βββ test.js # Comprehensive test suite
βββ test-teams-notifications.js # Teams notification testing script
βββ debug-token-refresh.js # Token refresh debugging utility
βββ update-tokens.js # Token update utility for local config
βββ update-github-secrets.js # GitHub repository secrets update utility
βββ deploy.sh # Automated deployment script for Linux
βββ crontab-setup.txt # Cron job configuration examples
βββ Dockerfile # Docker container configuration
βββ docker-compose.yml # Docker Compose configuration
βββ .dockerignore # Docker build optimization
βββ logs/ # Log files directory (created automatically)
βββ refresh.log # Token refresh logs
βββ credit.log # Credit loading logs
βββ error.log # Error logs
βββ test.log # Test execution logs
βββ teams-test.log # Teams notification test logs
βββ debug-token-refresh.log # Token refresh debug logs
βββ token-update.log # Token update logs
βββ github-secrets-update.log # GitHub secrets update logs
βββ cron.log # Cron job execution logs
- refresh.log: Token refresh operations
- credit.log: Credit loading operations
- error.log: All error messages
- cron.log: Cron job execution output
# View last 50 lines of refresh logs
tail -n 50 logs/refresh.log
# View last 50 lines of credit logs
tail -n 50 logs/credit.log
# View error logs
tail -n 50 logs/error.log
# Monitor logs in real-time
tail -f logs/refresh.log# Check if cron service is running
systemctl status cron
# View cron logs (Ubuntu/Debian)
grep CRON /var/log/syslog
# View cron logs (CentOS/RHEL)
grep CRON /var/log/messages-
Scripts not running via cron
- Check file permissions:
ls -la *.js - Verify Node.js path:
which node - Check cron service:
systemctl status cron
- Check file permissions:
-
Authentication errors (HTTP 401)
- Quick fix for local: Update tokens manually:
npm run update-tokens - Quick fix for GitHub Actions: Update repository secrets:
npm run update-github-secrets - Check current token status:
npm run token-status - Run detailed debug:
npm run debug-tokens - See
TOKEN-TROUBLESHOOTING.mdfor detailed solutions - Verify tokens in
config.jsonare current - Check if manual token refresh works:
npm run refresh-token
- Quick fix for local: Update tokens manually:
-
Missing dependencies
- Run
npm installin the project directory - Check Node.js version:
node --version
- Run
-
Permission denied errors
- Set proper permissions:
chmod +x *.js - Secure config file:
chmod 600 config.json
- Set proper permissions:
# Test token refresh manually
node refresh-token.js
# Test credit loading configuration
node load-credit.js --test
# Test credit loading (respects weekend check)
node load-credit.js
# Test Teams notifications
npm run test-teams-connection
# Test Teams notifications with full messages
npm run test-teams
# View Teams setup instructions
npm run teams-setup
# Debug token refresh issues
npm run debug-tokens
# Check current token status
npm run token-status
# Update tokens manually for local development
npm run update-tokens
# Update GitHub repository secrets for GitHub Actions
npm run update-github-secrets
# Get help for GitHub Personal Access Token setup
npm run github-token-helpAdd debug logging by modifying the log level in utils.js or check the detailed logs in the logs/ directory.
- Keep
config.jsonsecure with restricted permissions (600) - Regularly rotate authentication tokens
- Monitor log files for suspicious activity
- Consider using environment variables for sensitive data in production
The system interacts with these 10bis API endpoints:
- Token Refresh:
POST https://api.10bis.co.il/api/v1/Authentication/RefreshToken - Credit Loading:
PATCH https://api.10bis.co.il/api/v1/Payments/LoadTenbisCredit
- Token Refresh: Every 10 minutes, 24/7
- Credit Loading: Daily at 10:00 AM Israel time, Monday through Thursday and Sunday
- Weekend Skip: Automatically skips Friday and Saturday
For issues or questions:
- Check the log files in the
logs/directory - Verify your configuration in
config.json - Test scripts manually before troubleshooting cron issues
- Ensure all dependencies are installed with
npm install