Alert Workflow #3796
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 on every day-of-week from Monday through Friday | |
jobs: | |
alert-job: | |
runs-on: ubuntu-latest | |
container: | |
image: ghcr.io/doruirimescu/python-trading:${{ github.event.inputs.branchName || 'master' }} | |
steps: | |
- name: Set default branch name | |
id: vars | |
run: echo "::set-output name=branchName::${{ github.event.inputs.branchName || 'master' }}" | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
path: 'python-trading' # Checkout the repository into the 'app' directory | |
- 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 | |
echo "XTB_USERNAME=${{ secrets.XTB_USERNAME }}" >> $GITHUB_ENV | |
echo "XTB_PASSWORD=${{ secrets.XTB_PASSWORD }}" >> $GITHUB_ENV | |
echo "XTB_MODE=${{ secrets.XTB_MODE }}" >> $GITHUB_ENV | |
echo "BROKER_TIMEZONE=${{ secrets.BROKER_TIMEZONE }}" >> $GITHUB_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 }} |