{"id":20521310,"url":"https://github.com/charliegerard/event-triggered-netlify-function","last_synced_at":"2025-04-14T02:34:22.766Z","repository":{"id":78179625,"uuid":"388061459","full_name":"charliegerard/event-triggered-netlify-function","owner":"charliegerard","description":"Demo showing how to use event-triggered Netlify Functions.","archived":false,"fork":false,"pushed_at":"2021-07-21T12:07:06.000Z","size":9,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T16:40:05.569Z","etag":null,"topics":["javascript","netlify","netlify-functions","serverless"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charliegerard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-21T09:16:52.000Z","updated_at":"2024-11-07T12:27:51.000Z","dependencies_parsed_at":"2023-03-22T21:47:36.790Z","dependency_job_id":null,"html_url":"https://github.com/charliegerard/event-triggered-netlify-function","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charliegerard%2Fevent-triggered-netlify-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charliegerard%2Fevent-triggered-netlify-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charliegerard%2Fevent-triggered-netlify-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charliegerard%2Fevent-triggered-netlify-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charliegerard","download_url":"https://codeload.github.com/charliegerard/event-triggered-netlify-function/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248811496,"owners_count":21165309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","netlify","netlify-functions","serverless"],"created_at":"2024-11-15T22:28:05.063Z","updated_at":"2025-04-14T02:34:22.748Z","avatar_url":"https://github.com/charliegerard.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Event-triggered Netlify Functions\n\n[![Netlify Status](https://api.netlify.com/api/v1/badges/b52701dc-af05-4c69-a9d1-858aab2d3e74/deploy-status)](https://app.netlify.com/sites/event-triggered-function/deploys)\n\nThis is a small demo made with Vanilla JS :heart: to showcase how to use event-triggered Netlify Functions.\n\nThis site is deployed on Netlify and when a deploy fails, the function fetches a random GIF and posts it on a Slack channel.\n\n## Local development\n\nIf you'd like to try this demo locally, there's a few steps to follow:\n\n- Follow the [Giphy API docs](https://developers.giphy.com/docs/api#quick-start-guide) to get an API key.\n- Check the [Slack API docs](https://api.slack.com/) to create an app and get a user ID, channel ID and secret token.\n- Clone the repo.\n- In the `deploy-failed.js` file, replace the environment variables with your own:\n  - Either replace directly the `process.env.SOME_KEY` instances with the keys you generated (but don't forget to **not** commit your file), or:\n  - Create a `.env` file, place all your secrets in there and add `require('dotenv').path(\"path/to/your/.env/file\")` at the top of the function file (and .gitignore it if you decide to commit).\n- Run `netlify dev` in your terminal\n- Open `http://localhost:8888`\n- As this function is usually triggered by a build event, you'll need to write some custom code to trigger it locally, for example:\n\n```javascript\nwindow.onload = () =\u003e {\n  return fetch(\"/.netlify/functions/deploy-failed\");\n};\n```\n\nAnd if you followed all the above steps, you should get a new GIF on Slack! :tada:\n\n## Deploy on Netlify\n\n[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/charliegerard/event-triggered-netlify-function)\n\nThe fastest way to try this demo would be to deploy it on Netlify and add the following environment variables in the site's settings: `GIPHY_API_KEY`, `SLACK_API_SECRET`, `SLACK_CHANNEL_ID`, `SLACK_USER_ID`.\n\nTrigger a deploy, cancel it, get a GIF on Slack!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharliegerard%2Fevent-triggered-netlify-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharliegerard%2Fevent-triggered-netlify-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharliegerard%2Fevent-triggered-netlify-function/lists"}