Git Product home page Git Product logo

scheduler's Introduction

⚠️ This project is archived

We recommend you use GitHub Actions with the schedule trigger instead, it's a much more reliably solution to the same problem.

You can authenticate as your GitHub app when running code in a GitHub Action using the @octokit/auth-app authentication strategy.

Probot: Scheduler

npm

A Probot extension to trigger events on an hourly schedule.

Usage

$ npm install probot-scheduler
const createScheduler = require('probot-scheduler')

module.exports = (robot) => {
  createScheduler(robot)
  robot.on('schedule.repository', context => {
    // this event is triggered on an interval, which is 1 hr by default
  })
}

Configuration

There are a few environment variables that can change the behavior of the scheduler:

  • DISABLE_DELAY=true - Perform the schedule immediately on startup, instead of waiting for the random delay between 0 and 59:59 for each repository, which exists to avoid all schedules being performed at the same time.

  • IGNORED_ACCOUNTS=comma,separated,list - GitHub usernames to ignore when scheduling. These are typically spammy or abusive accounts.

Options

There are a few runtime options you can pass that can change the behavior of the scheduler:

  • delay - when false, the schedule will be performed immediately on startup. When true, there will be a random delay between 0 and interval for each repository to avoid all schedules being performed at the same time. Default: true unless the DISABLE_DELAY environment variable is set.

  • interval - the number of milliseconds to schedule each repository. Default: 1 hour (60 * 60 * 1000)

For example, if you want your app to be triggered once every day with delay enabled on first run:

const createScheduler = require('probot-scheduler')

module.exports = (robot) => {
  createScheduler(robot, {
    delay: !!process.env.DISABLE_DELAY, // delay is enabled on first run
    interval: 24 * 60 * 60 * 1000 // 1 day
  })
  
  robot.on('schedule.repository', context => {
    // this event is triggered once every day, with a random delay
  })
}

scheduler's People

Contributors

akosyakov avatar bkeepers avatar chrmarti avatar gr2m avatar hiimbex avatar jasonetco avatar lee-dohm avatar macklinu avatar nileshgulia1 avatar tcbyrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

scheduler's Issues

Use of `result.data.repositories` is deprecated

The use of result.data.repositories in octokit is deprecated:

{ Deprecation: [@octokit/rest] "result.data.repositories" is deprecated. Use "result.data" instead
    at Array.get (/Users/xxx/Workspace/bcdevx/repo-mountie/node_modules/@octokit/rest/plugins/pagination/normalize-paginated-list-response.js:59:39)
    at github.paginate.response (/Users/xxx/Workspace/bcdevx/probot-scheduler/index.js:96:30)
    at iterator.next.then.result (/Users/xxx/Workspace/bcdevx/repo-mountie/node_modules/@octokit/rest/plugins/pagination/paginate.js:26:40) name: 'Deprecation' }

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Refactor to be event-based

The current usage of visitor feels weird along side scripts that are largely event-based. I was thinking about how we could start to move to a more event-based pattern, and here's an idea:

const visitor = require('probot-visitor');

module.exports = robot => {
  // How often to schedule events, and the name of the event to schedule'
  visitor(robot).schedule('daily', 'sweep');

  robot.on('scheduled.sweep', (event, context) => {
    // event.payload.repository - repository object
    // event.payload.installation - installation object
    // context.github - authenticated GitHub client
  });
};

cc @lee-dohm

Add schedule.installation

Similar to firing an event that is fired for each connected repository, it would also be handy to have just one event for every installation.

Cannot set multiple schedulers

I want to make two schedulers one which runs each hour and one which runs every week day. I couldn't find a way of doing this currently with scheduler as all it's instances will trigger schedule.repository event. Is this currently doable ? I did find an alternate hacky solution but it's sub-optimal. If you feel the need for this feature I can make a PR for this.

Blocked repos keep getting scheduled

Background: A user has ~650 repos, out of which 2 forks are blocked because the parent repo is blocked.

Problem Description:
I found that the (DMCA or ToS) blocked repos don’t appear blocked when fetched using getInstallationRepositories. So filters wouldn’t really work.

Ideally probot-scheduler should just stop scheduling those repos.

  • Method 1. Ask Github to include some indication that repo is blocked so probot-scheduler can just skip it. (Con: Probably won't happen)
  • Method 2. Run a get repo call for each repo before scheduling. (Con: Overhead)

My temporary solution: Since I am using probot-config, I catch the error there and unschedule the repos.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Cannot read property 'merge' of undefined

With following dependencies:

{
    "probot": "^7.2.0",
    "probot-scheduler": "^2.0.0-beta.1",
}

Get:

11:49:10.467Z ERROR probot: Cannot read property 'merge' of undefined
  TypeError: Cannot read property 'merge' of undefined
      at eachInstallation (/Users/cchantep/Projects/pr-jira/node_modules/probot-scheduler/index.js:83:46)
      at <anonymous>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.