-
-
Save tddschn/a3da8a200f3599b29533e02945264d3f to your computer and use it in GitHub Desktop.
This file contains 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: NCDMV Reservation Check | |
on: | |
workflow_dispatch: | |
# uncomment the following to run every hour | |
# schedule: | |
# # every hour | |
# - cron: "0 * * * *" | |
jobs: | |
send-mail: | |
runs-on: ubuntu-latest | |
steps: | |
- name: setup python 3.12 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: install CLI tools | |
run: | | |
pipx install --python "$(which python3.12)" ncdmv-reservation | |
pipx install sendgrid-cli | |
- name: create openssl.cnf | |
run: | | |
command cat <<'EOF' > openssl.cnf | |
openssl_conf = openssl_init | |
[openssl_init] | |
ssl_conf = ssl_sect | |
[ssl_sect] | |
system_default = system_default_sect | |
[system_default_sect] | |
Options = UnsafeLegacyRenegotiation | |
EOF | |
- name: Send email | |
shell: bash | |
env: | |
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} | |
OPENSSL_CONF: ${{ github.workspace }}/openssl.cnf | |
run: | | |
echo "::group::NC DMV Driver License Office Availability" | |
ncdmv-driver-license-office-availability | tee ncdmv.json | |
echo "::endgroup::" | |
AVAIL="$(<ncdmv.json jq '.[] | select(.office_name == "Raleigh West") | .is_reservable' -r)" | |
MSG="Raleigh West is reservable: $AVAIL" | |
echo "$MSG" | |
# if false, don't exit 0 | |
if [[ "$AVAIL" == "false" ]]; then | |
echo 'not sending email' | |
exit 0 | |
fi | |
echo "$MSG" | sendgrid -f 'from@example.com' -n 'send-as-name' -t 'recipient@example.com' -s 'NC DMV Avail' -H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://teddysc.me/blog/ncdmv-reservation