Alert Workflow #5354
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: Alert Workflow | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branchName: | |
| description: 'Branch name to pull the image from' | |
| required: true | |
| default: 'master' | |
| schedule: | |
| - cron: '15 */2 * * 1-5' # Every 2nd hour Mon–Fri (runs in UTC) | |
| # If you rely on GITHUB_TOKEN instead of a PAT for pushes, uncomment: | |
| # permissions: | |
| # contents: write | |
| jobs: | |
| alert-job: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/doruirimescu/python-trading:${{ github.event.inputs.branchName || 'master' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: 'python-trading' | |
| - name: Create .env file | |
| run: | | |
| cd python-trading | |
| touch Trading/config/.env | |
| touch Trading/utils/.env | |
| echo 'EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}' >> Trading/config/.env | |
| echo 'EMAIL_RECIPIENTS=${{ secrets.EMAIL_RECIPIENTS }}' >> Trading/config/.env | |
| echo 'EMAIL_SENDER=${{ secrets.EMAIL_SENDER }}' >> Trading/config/.env | |
| echo 'EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}' >> Trading/utils/.env | |
| echo 'EMAIL_RECIPIENTS=${{ secrets.EMAIL_RECIPIENTS }}' >> Trading/utils/.env | |
| echo 'EMAIL_SENDER=${{ secrets.EMAIL_SENDER }}' >> Trading/utils/.env | |
| - name: Run alert scripts | |
| run: | | |
| cd python-trading | |
| ls -la | |
| bash script/alert_workflow.sh | |
| echo "Alerts sent" | |
| - name: Commit and push changes | |
| run: | | |
| cd python-trading | |
| ls -la | |
| git config --global user.name '${{ github.actor }}' | |
| git config --global user.email '${{ github.actor }}@users.noreply.github.com' | |
| git add . || true | |
| git commit -m "Add modified alert.json files" || true | |
| git push https://${{ secrets.MY_PAT }}@github.com/doruirimescu/python-trading HEAD:${{ github.event.inputs.branchName || 'master' }} || true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |