diff --git a/.github/workflows/check-wordpress-release.yml b/.github/workflows/check-wordpress-release.yml index 2785bf5..13acd47 100644 --- a/.github/workflows/check-wordpress-release.yml +++ b/.github/workflows/check-wordpress-release.yml @@ -2,6 +2,8 @@ name: Check for WordPress releases on: workflow_dispatch: + schedule: + - cron: '*/5 * * * *' defaults: run: @@ -25,4 +27,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }} - TRAVIS_API_KEY: ${{ secrets.TRAVIS_API_KEY }} diff --git a/.github/workflows/update-composer-package.yml b/.github/workflows/update-composer-package.yml index 64d8369..9fbca38 100644 --- a/.github/workflows/update-composer-package.yml +++ b/.github/workflows/update-composer-package.yml @@ -4,6 +4,8 @@ on: workflow_dispatch: repository_dispatch: types: [wordpress-release] + schedule: + - cron: '41 20 */1 * *' jobs: update: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 01f29b8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: generic -services: docker - -install: make init -script: make update diff --git a/cron/src/lib.js b/cron/src/lib.js index dec4a8c..095edc8 100644 --- a/cron/src/lib.js +++ b/cron/src/lib.js @@ -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'); @@ -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'); @@ -55,7 +50,7 @@ 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'}); @@ -63,7 +58,6 @@ async function sendRepoDispatchEvent(tag) { if (!response.ok) { throw new Error(`could not send dispatch event, status code ${response.status}`); } - return await response.json(); } async function getLatestReleaseInFeed() {