I have created a github actions script to check how a stock price is updating during the day (all details omitted for brevity in this post).
When the current price is higher than or equal to the price limit and the previous price is lower than the price limit
OR
When the current price is lower than or equal to the price limit and the previous price is higher than the price limit
a limit event occurs.
the code can be found below and also on this link
name: if conditional limit
on:
workflow_dispatch:
jobs:
scheduled:
runs-on: ubuntu-latest
steps:
- name: Check out this repo
uses: actions/checkout@v2
- name: Fetch latest data
run: |-
prev_price=9.88
cur_price=10.2
echo "this is the current price ${cur_price}"
echo "this is the previous price ${prev_price}"
price_limit=8.81
echo "this is the price limit ${price_limit}"
echo "GITHUB_PRICE_LIMIT=${price_limit}" >> $GITHUB_ENV
echo "GITHUB_CUR_PRICE=${cur_price}" >> $GITHUB_ENV
echo "GITHUB_PREV_PRICE=${prev_price}" >> $GITHUB_ENV
echo "GITHUB_MAIL_UPDATE=0" >> $GITHUB_ENV
- name: test for limit event
if: (((env.GITHUB_CUR_PRICE >= env.GITHUB_PRICE_LIMIT) && (env.GITHUB_PREV_PRICE < env.GITHUB_PRICE_LIMIT)) || ((env.GITHUB_CUR_PRICE <= env.GITHUB_PRICE_LIMIT) && (env.GITHUB_PREV_PRICE > env.GITHUB_PRICE_LIMIT)))
run: |-
echo "limit event occurred"
I am very new to github actions, so please bear with me if I have missed something. Also, if this isn't the idiomatic way to achieve the effect that I am after, please let me know.
Expected behaviour:
No limit event should occur (according to my understanding of the defined logic)



