luxysiv / Cloudflare-Gateway-Package

Upload dynamic ad-blocking rules to Cloudflare Gateway.
4 stars 13 forks source link

Cloudflare Workers to run Github Actions #4

Closed suricloud closed 3 months ago

suricloud commented 3 months ago

Hi,

Will you also update this cloudlare gateway package a with this new update to run github actions with cf workers ?

luxysiv commented 3 months ago

Yes I can

suricloud commented 3 months ago

Thanks for the update. I tried with github classic token, but didn''t worked in cf workers. Can you please explain more in details how to do it?

luxysiv commented 3 months ago

Screenshot_20240531_090017_Edge

suricloud commented 3 months ago

I created github token as showed here, creates a cf worker and pasted the code and made the changes as required. But no succes, i see this error in console;

2worker.js:233 Error: No response! at facade_sw_fetch (worker.js:176:15) at facade_invokeChain (worker.js:25:12) at Object.next (worker.js:22:16) at jsonError (worker.js:231:34) at facade_invokeChain (worker.js:25:12) at Object.next (worker.js:22:16) at scheduled (worker.js:213:26) at facade_invokeChain (worker.js:25:12) at facade_invoke (worker.js:28:12) at worker.js:181:43 jsonError @ worker.js:233

luxysiv commented 3 months ago

Try all permission and delete all content of old deleloyed on Cloudflare Workers page

luxysiv commented 3 months ago

Remember paste you see lastest line if has )} ,delete it

suricloud commented 3 months ago

I just pasted this? Created new cloudflare worker, deleted the existed demo code and then past this with my github token, github username en repos.

addEventListener('scheduled', event => { event.waitUntil(handleScheduledEvent()); });

async function handleScheduledEvent() { const GITHUB_TOKEN = 'YOUR_GITHUB_TOKEN_HERE'; try { const dispatchResponse = await fetch('https://api.github.com/repos/YOUR_USER_NAME/YOUR_REPO_NAME/actions/workflows/main.yml/dispatches', { method: 'POST', headers: { 'Authorization': Bearer ${GITHUB_TOKEN}, 'Content-Type': 'application/json', 'User-Agent': 'Mozilla/5.0', }, body: JSON.stringify({ ref: 'main' }), });

if (!dispatchResponse.ok) throw new Error('Failed to dispatch workflow');

} catch (error) { console.error('Error handling scheduled event:', error); } }

luxysiv commented 3 months ago

Change your toke, your account and repository name. Example : https://api.github.com/repos/luxysiv/Cloudflare-Gateway-Pihole/actions/workflows/main.yml/dispatches

suricloud commented 3 months ago

Screenshot 2024-06-01 074207

suricloud commented 3 months ago

Change your toke, your account and repository name. Example : https://api.github.com/repos/luxysiv/Cloudflare-Gateway-Pihole/actions/workflows/main.yml/dispatches

I have done, still getting same errors in console?

luxysiv commented 3 months ago

Try, I was test. It's work

luxysiv commented 3 months ago

I created github token as showed here, creates a cf worker and pasted the code and made the changes as required. But no succes, i see this error in console;

2worker.js:233 Error: No response! at facade_sw_fetch (worker.js:176:15) at facade_invokeChain (worker.js:25:12) at Object.next (worker.js:22:16) at jsonError (worker.js:231:34) at facade_invokeChain (worker.js:25:12) at Object.next (worker.js:22:16) at scheduled (worker.js:213:26) at facade_invokeChain (worker.js:25:12) at facade_invoke (worker.js:28:12) at worker.js:181:43 jsonError @ worker.js:233

Don't care About log error Screenshot_20240601_180037_Edge Screenshot_20240601_180125_Edge Screenshot_20240601_180145_Edge

suricloud commented 3 months ago

can you sent the full screenshot of cf workers you added? mine seems to be different and my errors are different en in red color. Something is not good my side.Want to know where and what to correct.

luxysiv commented 3 months ago

can you sent the full screenshot of cf workers you added? mine seems to be different and my errors are different en in red color. Something is not good my side.Want to know where and what to correct.

The same, see my console log. Don't worry about it.Code is ok

suricloud commented 3 months ago

should cron trigger to be set to 1 minute? This will update then update github and filters evry minute?

luxysiv commented 3 months ago

1 day, Github Action limited

suricloud commented 3 months ago

ok,thanks. Will see how this work out :)

suricloud commented 3 months ago

is this ok

0 /23 | At 0 minutes past the hour, every 23 hours

luxysiv commented 3 months ago

Screenshot_20240604_082947_Edge It's easy to configure.

suricloud commented 3 months ago

ok :)

luxysiv commented 3 months ago

Code now won’t fail if Cloudflare’s server is normal