0

I know how to run a cron job on the first thursday of every month, as per this post: How to schedule a cron for the first Thursday of every month

I'm wanting to do this within a GitHub Action though, and I don't believe it supports the additional commands?

My yaml is as follows, but obviously the cron is completely wrong. Any suggestions?

name: daily-cron-job
on:
  schedule:
    - cron: '0 2 * * *'
jobs:
  cron:
    runs-on: ubuntu-latest
    steps:
      - name: populate-previous-month
        run: |
          curl --request POST \
          --url 'https://example.com' \
          --header 'Authorization: Bearer ${{ secrets.ACTION_KEY }}'
K20GH
  • 6,032
  • 20
  • 78
  • 118
  • Seems like you could set this up to run every Thursday, then exit if the day-of-month is above seven. That's what the cronjob solutions are doing. – Nick ODell Nov 30 '21 at 21:27
  • Don't suppose you know how to do that in actions? I'm not too familiar with them – K20GH Nov 30 '21 at 21:35

1 Answers1

1

Here's the idea of Nick ODell. I haven't tested that it really runs though.

name: daily-cron-job
on:
  schedule:
    - cron: '0 2 * * THU'

jobs:
  cron:
    runs-on: ubuntu-latest
    steps:
      - name: populate-previous-month
        run: |
          if [ `date +'%d' | sed 's/^0*//'` -le 7 ]; then
            echo "hello first thursday of the month"
          else
            echo "didn't match"
          fi
banyan
  • 3,837
  • 2
  • 31
  • 25