Schwab Token Auto Refresher #42
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: Schwab Token Auto Refresher | |
| on: | |
| schedule: | |
| - cron: '0 13 */3 * *' | |
| workflow_dispatch: | |
| jobs: | |
| refresh-token: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Google Chrome & Dependencies | |
| run: | | |
| sudo apt-get update | |
| wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb | |
| sudo apt install -y ./google-chrome-stable_current_amd64.deb | |
| npm install | |
| - name: Run Refresh Script | |
| run: npm start | |
| env: | |
| GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
| SCHWAB_USERNAME: ${{ secrets.SCHWAB_USERNAME }} | |
| SCHWAB_PASSWORD: ${{ secrets.SCHWAB_PASSWORD }} | |
| SCHWAB_TOTP_SECRET: ${{ secrets.SCHWAB_TOTP_SECRET }} | |
| SCHWAB_API_KEY: ${{ secrets.SCHWAB_API_KEY }} | |
| SCHWAB_APP_SECRET: ${{ secrets.SCHWAB_APP_SECRET }} | |
| GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| GCP_SECRET_ID: ${{ secrets.GCP_SECRET_ID }} | |
| SCHWAB_REDIRECT_URI: ${{ secrets.SCHWAB_REDIRECT_URI }} | |
| - name: Upload Error Screenshot | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: debug-screenshots | |
| path: '*.png' | |
| - name: Update Log (Bash Version) | |
| if: success() | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| echo "Last successful refresh: $(date '+%Y-%m-%d %H:%M:%S')" > last_run.txt | |
| git checkout -B logs | |
| git add last_run.txt | |
| git commit -m "chore: update token refresh log [skip ci]" | |
| git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" logs --force |