Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub actions schedule #28

Merged
merged 3 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/check-wordpress-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Check for WordPress releases

on:
workflow_dispatch:
schedule:
- cron: '*/5 * * * *'

defaults:
run:
Expand All @@ -25,4 +27,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
TRAVIS_API_KEY: ${{ secrets.TRAVIS_API_KEY }}
2 changes: 2 additions & 0 deletions .github/workflows/update-composer-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
workflow_dispatch:
repository_dispatch:
types: [wordpress-release]
schedule:
- cron: '41 20 */1 * *'

jobs:
update:
Expand Down
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

12 changes: 3 additions & 9 deletions cron/src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const last = function (arr) {
return [].concat(arr).pop()
};

async function github(endpoint, {method, body} = {method: 'GET'}) {
async function github(endpoint, options = {}) {
const headers = new fetch.Headers();
headers.append('User-Agent', 'roots-ladybug');
headers.append('Accept', 'application/vnd.github.v3+json');
Expand All @@ -17,12 +17,7 @@ async function github(endpoint, {method, body} = {method: 'GET'}) {
headers.append('Authorization', `token ${token}`)
}
const requestUrl = url.resolve('https://api.github.com', endpoint);

if method === 'POST' {
const response = await fetch(requestUrl, {method, body, headers});
} else {
const response = await fetch(requestUrl, {method, headers});
}
const response = await fetch(requestUrl, {headers, ...options});

if ([401, 403].includes(response.status)) {
const remaining = response.headers.get('X-RateLimit-Remaining');
Expand Down Expand Up @@ -55,15 +50,14 @@ async function notifySlack(msg) {
async function sendRepoDispatchEvent(tag) {
const body = {
event_type: 'wordpress-release',
client_payload: { version: tag },
client_payload: { version: tag }
};

const response = await github('/repos/roots/wordpress/dispatches', {body: JSON.stringify(body), method: 'POST'});

if (!response.ok) {
throw new Error(`could not send dispatch event, status code ${response.status}`);
}
return await response.json();
}

async function getLatestReleaseInFeed() {
Expand Down