Skip to content

Commit

Permalink
feat: 🎸 support cron and weather trigger
Browse files Browse the repository at this point in the history
We support cron expression now. You can use it at 'config.every'.
@actionsflow/trigger-weather is released now.

✅ Closes: #9
  • Loading branch information
theowenyoung committed Oct 11, 2020
1 parent 2616ade commit 33d11ab
Show file tree
Hide file tree
Showing 115 changed files with 6,417 additions and 790 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Expand Up @@ -14,6 +14,9 @@ module.exports = {
},
extends: ["plugin:jest/recommended", "prettier"],
plugins: ["jest"],
rules: {
"no-console": ["error", { allow: ["warn", "error"] }],
},
overrides: [
{
// enable the rule specifically for TypeScript files
Expand Down
1 change: 0 additions & 1 deletion .release-it.json
@@ -1,7 +1,6 @@
{
"git": {
"commitMessage": "chore(release): 🤖 v${version}",
"requireBranch": "main",
"requireCommits": false,
"tagName": "v${version}",
"push": true
Expand Down
2 changes: 1 addition & 1 deletion .releaseflag
@@ -1 +1 @@
patch
prerelease
82 changes: 82 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,85 @@
# [1.2.0-10](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-typeform@1.1.0-alpha.8...v1.2.0-10) (2020-10-11)


### Features

* weather ([a18d1fd](https://github.com/actionsflow/actionsflow/commit/a18d1fd3d27db8a287452381eaf0d38470ea2993))

# [1.2.0-9](https://github.com/actionsflow/actionsflow/compare/actionsflow-workflow-example@1.2.0-alpha.10...v1.2.0-9) (2020-10-11)


### Bug Fixes

* github action ([31fb6a8](https://github.com/actionsflow/actionsflow/commit/31fb6a8a8aed8748ac621e5c0172446cd34db0c7))

# [1.2.0-8](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.7...v1.2.0-8) (2020-10-11)


### Bug Fixes

* every ([a5beb8a](https://github.com/actionsflow/actionsflow/commit/a5beb8a29b62e3945e03be45e0110151a7191a8e))

# [1.2.0-7](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.6...v1.2.0-7) (2020-10-11)


### Bug Fixes

* debug log ([5a6d01a](https://github.com/actionsflow/actionsflow/commit/5a6d01a3db647662fd31c0cd9f99c1da4e0a74b1))

# [1.2.0-6](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.5...v1.2.0-6) (2020-10-10)


### Bug Fixes

* global options ([a49652a](https://github.com/actionsflow/actionsflow/commit/a49652a3210f4901b06e1449c9859007cdecb6b5))

# [1.2.0-5](https://github.com/actionsflow/actionsflow/compare/actionsflow-workflow-example@1.2.0-alpha.6...v1.2.0-5) (2020-10-10)


### Bug Fixes

* name ([b736a47](https://github.com/actionsflow/actionsflow/commit/b736a479c3fdb088210adfc3a078f50ecde116c6))

# [1.2.0-4](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-telegram_bot@1.1.0-alpha.5...v1.2.0-4) (2020-10-10)


### Bug Fixes

* task order ([044c23e](https://github.com/actionsflow/actionsflow/commit/044c23e00afff6dc5e85b4bfa93c15a2773a5f65))

# [1.2.0-3](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.4...v1.2.0-3) (2020-10-10)


### Features

* task ([c005e79](https://github.com/actionsflow/actionsflow/commit/c005e79fa54fa0e2d275d391578a7a9ff9e6358a))

# [1.2.0-2](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.3...v1.2.0-2) (2020-10-10)


### Features

* manual ([1fe186d](https://github.com/actionsflow/actionsflow/commit/1fe186dcce7c284808c81225c730445024dbe2d7))

# [1.2.0-1](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-npm@1.1.0-alpha.2...v1.2.0-1) (2020-10-10)

# [1.2.0-0](https://github.com/actionsflow/actionsflow/compare/v1.1.5-1...v1.2.0-0) (2020-10-10)


### Bug Fixes

* cron dependence ([b13c4b4](https://github.com/actionsflow/actionsflow/commit/b13c4b41b4c7823ede1af76ec3c73630161ba13a))

## [1.1.5-1](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.1...v1.1.5-1) (2020-10-10)

## [1.1.5-0](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.1.0-alpha.0...v1.1.5-0) (2020-10-10)


### Features

* no allow ([c2a3ab8](https://github.com/actionsflow/actionsflow/commit/c2a3ab8ee86e6bfc02d8e54574ead7e87b264364))
* support cron every ([5c85545](https://github.com/actionsflow/actionsflow/commit/5c85545c4ed86d0722cad3e6645dd667442257a1))

## [1.1.4](https://github.com/actionsflow/actionsflow/compare/@actionsflow/trigger-aws_sns@1.0.4...v1.1.4) (2020-10-06)

## [1.1.3](https://github.com/actionsflow/actionsflow/compare/actionsflow-workflow-example@1.1.3...v1.1.3) (2020-10-05)
Expand Down
5 changes: 4 additions & 1 deletion dictionary.txt
Expand Up @@ -67,4 +67,7 @@ DingDing
dingding
Mattermost
args
Youtube
Youtube
SIGNL4
param
Openweathermap
2 changes: 1 addition & 1 deletion docs/about.md
Expand Up @@ -5,7 +5,7 @@ metaTitle: "About Actionsflow"

[Actionsflow](https://github.com/actionsflow/actionsflow) helps you automate workflows - it's a free [IFTTT](https://ifttt.com/)/[Zapier](https://zapier.com/) alternative for developers. With [Actionsflow](https://github.com/actionsflow/actionsflow) you can connect your favorite apps, data, and APIs, receive notifications of actions as they occur, sync files, collect data, and more. We implemented it based on [Github actions](https://docs.github.com/en/actions), and you use a YAML file to build your workflows. The configuration format is the same as [Github actions](https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow), which makes it easy for you to get going if you've explored Github actions before. You can also use any [Github actions](https://github.com/marketplace?type=actions) as your job's steps.

I ([@theowenyoung](https://github.com/theowenyoung)) started this project because I needed to perform an action everytime a specific RSS feed was updated, but I couldn't find a free platform with support for complicated workflows. I want to thank Github for providing the [Github actions](https://github.com/features/actions) CI platform for free for open source projects. Leveraging Github actions, Actionsflow provides support for workflows that aren't easily supported by Github actions alone yet.
I ([@theowenyoung](https://github.com/theowenyoung)) started this project because I needed to perform an action every time a specific RSS feed was updated, but I couldn't find a free platform with support for complicated workflows. I want to thank Github for providing the [Github actions](https://github.com/features/actions) CI platform for free for open source projects. Leveraging Github actions, Actionsflow provides support for workflows that aren't easily supported by Github actions alone yet.

Here are some useful links:

Expand Down
4 changes: 3 additions & 1 deletion docs/faqs.md
Expand Up @@ -17,7 +17,7 @@ individuals, we have a number of open channels for communication.

## 1. How to set a scheduled/cron event?

Actionsflow does not support schedule event, because Github actions support the scheduled event, you can use [Github actions](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events) to do it if you want.
Yes, you can set a cron event on Actionsflow, see [`on.<trigger>.config.every`](workflow.md#ontriggerconfigevery)

## 2. How to debug trigger outputs?

Expand All @@ -41,6 +41,8 @@ jobs:

## 3. How to debug?

If you want to debug a specific trigger, you can pass [`debug: true`](workflow.md#ontriggerconfigdebug) to the trigger.

If some errors occur, maybe you want to debug it. To enable Github Actions step debug logging, you must set the following secret in the repository that contains the workflow: `ACTIONS_STEP_DEBUG` to true. If so, Actionsflow will set `logLevel: debug`, so you can debug the details. For more about debug please see [Enabling debug logging
](https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/enabling-debug-logging)

Expand Down
19 changes: 15 additions & 4 deletions docs/reference/trigger-api.md
Expand Up @@ -69,8 +69,12 @@ interface ITriggerContructorParams {

```typescript
interface ITriggerGeneralConfigOptions {
every?: number;
every?: number | string;
timeZone?: string;
shouldDeduplicate?: boolean;
manualRunEvent?: ManualRunTriggerEventType | ManualRunTriggerEventType[];
skipSchedule?: boolean;
debug?: boolean;
skipFirst?: boolean;
force?: boolean;
logLevel?: LogLevelDesc;
Expand Down Expand Up @@ -142,8 +146,12 @@ optional, `ITriggerGeneralConfigOptions`, you can change the default config by p

```yaml
interface ITriggerGeneralConfigOptions {
every?: number;
every?: number | string;
timeZone?: string;
shouldDeduplicate?: boolean;
manualRunEvent?: ManualRunTriggerEventType | ManualRunTriggerEventType[];
skipSchedule?: boolean;
debug?: boolean;
skipFirst?: boolean;
force?: boolean;
logLevel?: LogLevelDesc;
Expand All @@ -165,14 +173,17 @@ The default value is:

```json
{
"every": 5,
"every": 0,
"shouldDeduplicate": true,
"skipFirst": false,
"force": false,
"logLevel": "info",
"active": true,
"skipOnError": false,
"buildOutputsOnError": false
"buildOutputsOnError": false,
"timeZone": "UTC",
"shouldRunManually": true,
"manualRunEvent": []
}
```

Expand Down
11 changes: 11 additions & 0 deletions docs/reference/trigger-helpers.md
Expand Up @@ -18,6 +18,7 @@ interface IHelpers {
};
log: Logger;
axios: AxiosStatic;
rssParser: typeof Parser;
}
```

Expand Down Expand Up @@ -117,3 +118,13 @@ const binaryData = helpers.formatBinary(Buffer.from("test"));
console.log(binaryData.data === "dGVzdA==");
console.log(binaryData.mimeType === "text/plain");
```

# `rssParser`

A small function for turning RSS XML feeds into JavaScript objects. Actionsflow use [`rss-parser`](https://github.com/rbren/rss-parser) to parse a RSS feed.

```javascript
const response = await this.helpers.axios(options);
```

See [RSS Parser documentation](https://github.com/rbren/rss-parser)
1 change: 1 addition & 0 deletions docs/triggers.md
Expand Up @@ -29,6 +29,7 @@ For now, the following triggers are available:
- [Trello](https://github.com/actionsflow/actionsflow/tree/main/packages/actionsflow-trigger-trello) - Watch any action updates of trello
- [Twitter](https://github.com/actionsflow/actionsflow/tree/main/packages/actionsflow-trigger-twitter) - Watch twitter's timeline updates
- [Typeform](https://github.com/actionsflow/actionsflow/tree/main/packages/actionsflow-trigger-typeform) - Get form response updates when someone submitted
- [Weather](https://github.com/actionsflow/actionsflow/tree/main/packages/actionsflow-trigger-weather) - Get weather updates
- [Youtube](https://github.com/actionsflow/actionsflow/tree/main/packages/actionsflow-trigger-youtube) - Get Youtube channel or playlist video updates

## Community Triggers
Expand Down
48 changes: 41 additions & 7 deletions docs/workflow.md
Expand Up @@ -81,6 +81,32 @@ on:

The `config` has the following options.

## `on.<trigger>.config.every`

Optional, `number` or `string`, the interval time of running trigger, if `every` value type is `number`, the unit is minute. The default value is `0`, witch means the trigger will be ran once every Github Actionsflow workflow runs. But due to the limitation of the [shortest interval of github actions](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule), generally Actionsflow will run once every 5 minutes.

You can use `number` to specify the interval time of running trigger, like `60`, means the trigger will be ran once per 60 minutes. You can also use [cron expression](https://en.wikipedia.org/wiki/Cron) for `every` option, Like every 60 minutes, you can use `1 * * * *` instead. We use [`cron-parser`](https://github.com/harrisiirak/cron-parser#readme) to parse cron expression, with cron, you can define a more complex trigger schedule.

For example, if you want run a trigger at 7:00 AM weekly, you can use the following config:

Or, use cron expression:

```yaml
on:
rss:
url: https://hnrss.org/newest?points=300
config:
every: "0 7 * * 1-5"
```

> Note, the default time zone is `UTC`, so if you set a cron expression, you should notice it. You can also change the time zone by `on.<trigger>.config.timeZone`
> Note, webhook event will ignore `every` config
## `on.<trigger>.config.timeZone`

Optional, `string`, time zone, the default value is `UTC`, used for parsing `on.<trigger>.config.every` cron expression, see more time zone string at [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

## `on.<trigger>.config.filter`

Optional, [`MongoDB query language`](https://docs.mongodb.com/manual/tutorial/query-documents/index.html). You can use `filter` to filter the trigger's results as you need.
Expand Down Expand Up @@ -178,11 +204,9 @@ Optional, `number`, the trigger's results max length, the default value is `unde

Optional, `number`, skip `<count>` results of the trigger's results , the default value is `undefined`, it means the trigger will handle all items

## `on.<trigger>.config.every`

Optional, `number`, polling data interval time, the unit is minute, the default value is `0`, means the trigger will be ran every time. But due to the limitation of the [shortest interval of github actions](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule), generally Actionsflow will run once every 5 minutes, but you can also trigger Actionsflow run through `push` or the [other events that trigger Actionsflow run](https://docs.github.com/en/actions/reference/events-that-trigger-workflows)
## `on.<trigger>.config.active`

> Note, webhook event will ignore `every` config
Optional, `boolean`, if the trigger is active, default is `true`. for some reason, you can make trigger inactive by set `active: false`

## `on.<trigger>.config.skipFirst`

Expand All @@ -192,9 +216,15 @@ Optional, `boolean`, whether to skip the data obtained for the first time, if `t

Optional, `boolean`, if the trigger's results should be dedeplicate, the default value is decided by the trigger, you can force to override it.

## `on.<trigger>.config.manualRunEvent`

Optional, `string` or `string[]`, github actions events that should trigger this trigger run manually, the default value is `[]`, you can use `push`, `workflow_dispatch`, `repository_dispatch` as `manualRunEvent` value.

For example, if you set a trigger `every` as `1 2 * * *`, then, you don't wait to `02:01` to test your trigger, you can config `workflow_dispatch` as a trigger's `manualRunEvent`, then, if a [`workflow_dispatch`](https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch) event occurred, your trigger will be triggered.

## `on.<trigger>.config.force`

Optional, `boolean`, whether to force data to be updated, if `true`, the trigger will ignore cache, and last update time. The default value is `false`
Optional, `boolean`, whether to force data to be updated, if `true`, the trigger will ignore cache, every, and last update time. The default value is `false`

## `on.<trigger>.config.skipOnError`

Expand All @@ -208,9 +238,13 @@ Optional, `boolean`, Set to `true`, Actionsflow will build a workflow with `on.<

Optional, `string`, log level for trigger, the default value is `info`, you can use `trace`, `debug`, `info`, `warn`, `error`

## `on.<trigger>.config.active`
## `on.<trigger>.config.debug`

Optional, `boolean`, if the trigger is active, default is `true`. for some reason, you can make trigger inactive by set `active: false`
Optional, `boolean`, if debug the trigger, the default value is `false`, if `true`, then the `logLevel` will be `debug`, and the trigger will be triggered when all events occurred, like `push`, `workflow_dispatch`, `repository_dispatch`

## `on.<trigger>.config.skipSchedule`

Optional, `boolean`, if should skip schedule event, the default is `false`, if `true`, the trigger will ignore `every` param, not triggered by `schedule` event, use this param when you want a trigger run only manually.

## `on.<trigger>.<param>`

Expand Down

0 comments on commit 33d11ab

Please sign in to comment.