Skip to content

How to trigger workflow run once a week if push has occurred? #26519

Answered by BrightRan
benstear asked this question in Actions
Discussion options

You must be logged in to vote

@benstear ,

If you want your workflow run weekly, you need to set Scheduled events for the workflow.
If you want the workflow runs only when have pushes in that week, you need to compare whether the commit SHA ( github.sha ) of current workflow run is different with that of the last workflow run.
You can use cache action to store and pass the commit SHA in each workflow run.

A simple demo:

on:
  schedule:
    - cron: '0 0 * * 0'

jobs:
test_schedule:
name: Test schedule
runs-on: ubuntu-latest
steps:
- name: Create cache file
run: |
mkdir check-SHA
echo ${{ github.sha }} > github-sha.txt

  - name: Check SHA
    id: check_sha
    uses: actions/cache@v1
    with:
      path: check-SHA
      k…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@EricZinda
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants