[GH-ISSUE #97] Configure cron job on Circle CI #82

Closed
opened 2026-05-05 11:26:21 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @enocom on GitHub (Feb 4, 2019).
Original GitHub issue: https://github.com/enocom/gopher-reading-list/issues/97

One of the things we lost when transferring to Circle CI was running a build every 24 hours.

@mvxt If you have the time to do this, I would be grateful. Otherwise, I'm happy to handle it. You've done all the hard work.

Originally created by @enocom on GitHub (Feb 4, 2019). Original GitHub issue: https://github.com/enocom/gopher-reading-list/issues/97 One of the things we lost when transferring to Circle CI was running a build every 24 hours. @mvxt If you have the time to do this, I would be grateful. Otherwise, I'm happy to handle it. You've done all the hard work.
Author
Owner

@mvxt commented on GitHub (Feb 4, 2019):

@enocom Here's one of the snippets I've used to configure nightly builds.

In short you'll want to specify workflows. So I'd add the following snippets to your config.yml file:

workflows:
  version: 2
  build-pipeline:
    jobs:
      - build

  nightly:
    jobs:
      - build
    triggers:
      - schedule:
          cron: "0 6 * * *"
          filters:
            branches:
              only:
                - master

workflows is a top-level item with version specification followed by various other parameters. In the above snippet we've defined two workflows: the first is the normal workflow which is always triggered on push to repo.

The second one is the one that is triggered to run once a day via CRON. I also added an additional filter so that we only run nightly builds on the master branch, and no other branches. You can omit that if you'd like.

Hope this makes sense and helps.

The "build-pipeline" and "nightly" workflow labels are just names you can arbitrarily change. What's important is that the "jobs" section underneath lists the exact job names for jobs you've defined above.

Actually, I think that since your main job is just called "build" you might not even need to specify the 1st workflow because by default CircleCI implicitly looks for a build job. If you decide to rename the "build" job to something else though then you'll need to specify a workflow for it so CircleCI knows what job it should look for.

<!-- gh-comment-id:460457471 --> @mvxt commented on GitHub (Feb 4, 2019): @enocom Here's one of the snippets I've used to configure nightly builds. In short you'll want to specify workflows. So I'd add the following snippets to your config.yml file: ``` workflows: version: 2 build-pipeline: jobs: - build nightly: jobs: - build triggers: - schedule: cron: "0 6 * * *" filters: branches: only: - master ``` `workflows` is a top-level item with version specification followed by various other parameters. In the above snippet we've defined two workflows: the first is the normal workflow which is always triggered on push to repo. The second one is the one that is triggered to run once a day via CRON. I also added an additional filter so that we only run nightly builds on the master branch, and no other branches. You can omit that if you'd like. Hope this makes sense and helps. The "build-pipeline" and "nightly" workflow labels are just names you can arbitrarily change. What's important is that the "jobs" section underneath lists the exact job names for jobs you've defined above. Actually, I think that since your main job is just called "build" you might not even need to specify the 1st workflow because by default CircleCI implicitly looks for a `build` job. If you decide to rename the "build" job to something else though then you'll need to specify a workflow for it so CircleCI knows what job it **should** look for.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/gopher-reading-list#82
No description provided.