{"id":15673214,"url":"https://github.com/geopjr/co2","last_synced_at":"2025-05-06T22:24:34.316Z","repository":{"id":40475355,"uuid":"434623878","full_name":"GeopJr/CO2","owner":"GeopJr","description":"A GitHub action that notifies you about your website's carbon emissions and gives you some fun facts about it","archived":false,"fork":false,"pushed_at":"2023-03-16T23:45:26.000Z","size":46,"stargazers_count":17,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-19T15:53:11.823Z","etag":null,"topics":["actions","carbon-emissions","ci","co2","ecology","planet","renewable-energy"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/co2-ci","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GeopJr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-12-03T14:25:40.000Z","updated_at":"2024-09-22T05:35:33.000Z","dependencies_parsed_at":"2023-01-04T15:06:11.356Z","dependency_job_id":"bb8cf9e6-6bc0-42d6-bd2a-a7a4366d3201","html_url":"https://github.com/GeopJr/CO2","commit_stats":{"total_commits":11,"total_committers":3,"mean_commits":"3.6666666666666665","dds":0.5454545454545454,"last_synced_commit":"5d41ab048a15abfe7a429f9d7a0c55547361d1ac"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeopJr%2FCO2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeopJr%2FCO2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeopJr%2FCO2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GeopJr%2FCO2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GeopJr","download_url":"https://codeload.github.com/GeopJr/CO2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252777723,"owners_count":21802641,"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":["actions","carbon-emissions","ci","co2","ecology","planet","renewable-energy"],"created_at":"2024-10-03T15:38:32.071Z","updated_at":"2025-05-06T22:24:34.240Z","avatar_url":"https://github.com/GeopJr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e🌱 CO2 🔥\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eGet notified about your website's carbon emissions using GitHub Actions\u003c/h4\u003e\n\u003cp align=\"center\"\u003e\n  \u003cbr /\u003e\n    \u003ca href=\"https://github.com/GeopJr/CO2/blob/main/CODE_OF_CONDUCT.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/Contributor%20Covenant-v2.1-86d72a.svg?style=for-the-badge\u0026labelColor=6c4331\" alt=\"Code Of Conduct\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/GeopJr/CO2/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/LICENSE-BSD--2--Clause-86d72a.svg?style=for-the-badge\u0026labelColor=6c4331\" alt=\"BSD-2-Clause\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n#\n\n## How does CO2 (the action) work?\n\nCO2 (the action) will calculate your website's carbon emissions based on the amount of data it transfers to the client, as well as notify you if your host is using renewable or bog standard energy, along with how much CO2 you could not emit by switching to one that uses renewable energy (if not on one already).\nSome fun (or not so fun) facts about it in the long run will also be included!\n\nTo stay on par with [Website Carbon Calculator](https://websitecarbon.com/) without spamming their API, the same functions happen locally.\nThis includes their [calculations](https://gitlab.com/wholegrain/carbon-api-2-0) as well as their way of getting the amount transferred data (lighthouse).\n\nThe renewable energy data is provided by the [The Green Web Foundation](https://www.thegreenwebfoundation.org/), however since it relies on an external API, it is disabled by default.\n\nLastly, the action will:\n\n- print the results on the action log\n- comment on the commit that caused the push event to be emitted\n- comment on the PR that caused a pull_request event to be emitted\n\nThe action uses a prebuilt Docker image based on node:lts-slim with chromium and pnpm. You can find it on [Dockerfile.base](./Dockerfile.base). During building, [Dockerfile.base.dockerignore](./Dockerfile.base.dockerignore) replaces [.dockerignore](./.dockerignore).\n\n#\n\n## Installation\n\nA basic workflow would be:\n\n```yaml\n# .github/workflows/CO2.yaml\nname: Calculate CO2 🌱\n# You can remove any you don't want\non: [push, pull_request]\n\njobs:\n  audit:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Calculate CO2 🌱\n        uses: GeopJr/CO2@v1\n        with:\n          url: \"https://geopjr.dev/\"\n          renewable: true\n```\n\n### Input\n\n| Key         |       Default       | Required | Description                                                                    |\n| ----------- | :-----------------: | :------: | ------------------------------------------------------------------------------ |\n| `url`       |          -          |    ✅    | The url to check (please include the protocol eg. `https://`)                  |\n| `comment`   |       `true`        |    ❌    | Whether to create commit \u0026 PR comments                                         |\n| `token`     | `${{github.token}}` |    ❌    | Token used for creating comments                                               |\n| `renewable` |       `false`       |    ❌    | Whether to check if the website uses renewable energy (calls external service) |\n| `nerds`     |       `true`        |    ❌    | Whether to include 'Stats for nerds' (comment only)                            |\n| `footer`    |       `true`        |    ❌    | Whether to include the footer (comment only)                                   |\n\n#\n\n## Combinations\n\nYou can combine actions and create cases for more control, here's some:\n\n\u003cdetails\u003e\u003csummary\u003eConditional based on event\u003c/summary\u003e\n\n```yaml\n# .github/workflows/CO2.yaml\nname: Calculate CO2 🌱\n\non: [push, pull_request]\n\njobs:\n  audit:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Calculate CO2 🌱 on push\n        if: github.event_name == 'push'\n        uses: GeopJr/CO2@v1\n        with:\n          url: \"https://gnome.org/\"\n          renewable: true\n\n      - name: Calculate CO2 🌱 on PR\n        if: github.event_name == 'pull_request'\n        uses: GeopJr/CO2@v1\n        with:\n          url: \"https://kde.org/\"\n          renewable: true\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eAfter Netlify finishes a preview\u003c/summary\u003e\n\nThis uses an external actions, please read the following before using:\n\n- https://github.com/JakePartusch/wait-for-netlify-action\n\n```yaml\n# .github/workflows/CO2.yaml\nname: Calculate CO2 🌱\n\non: [push, pull_request]\n\njobs:\n  audit:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Waiting for Netlify to finish the preview\n        uses: jakepartusch/wait-for-netlify-action@v1.3\n        id: netlify\n        with:\n          site_name: \"replaceme\"\n          max_timeout: 60\n      - name: Calculate CO2 🌱\n        uses: GeopJr/CO2@v1\n        with:\n          url: \"${{ steps.netlify.outputs.url }}\"\n          renewable: true\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eAfter Vercel finishes a preview\u003c/summary\u003e\n\nThis uses an external actions, please read the following before using:\n\n- https://github.com/zentered/vercel-preview-url\n- https://github.com/UnlyEd/github-action-await-vercel\n\n```yaml\n# .github/workflows/CO2.yaml\nname: Calculate CO2 🌱\n\non: [push, pull_request]\n\njobs:\n  audit:\n    runs-on: ubuntu-latest\n    steps:\n      - run: sleep 60\n      - name: Waiting for Vercel to finish the preview\n        uses: zentered/vercel-preview-url@v1.0.0\n        id: vercel\n        env:\n          VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}\n        with:\n          vercel_team_id: \"replaceme\"\n          vercel_project_id: \"replaceme.com\"\n      - name: Calculate CO2 🌱\n        uses: GeopJr/CO2@v1\n        with:\n          url: \"https://${{ steps.vercel.outputs.preview_url }}\"\n          renewable: true\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eAdditional conditions\u003c/summary\u003e\n\n```yaml\n# Only run on commits that have \"[CO2]\" in their title\nif: \"contains(github.event.head_commit.message, '[CO2]')\"\n# Only run on commits that don't have \"[skip-CO2]\" in their title\nif: \"!contains(github.event.head_commit.message, '[skip-CO2]')\"\n# Check if it's a PR from the same repo (not a fork)\nif: github.event.pull_request.head.repo.full_name == github.repository\n# Run only when a file in a certain folder changes\non:\n  push: # pull_request also works\n    paths:\n      - 'website/'\n```\n\n\u003c/details\u003e\n\n#\n\n## Screenshots\n\n\u003cdetails\u003e\u003csummary\u003eCommit comment\u003c/summary\u003e\n\n\u003cimg src=\"https://i.imgur.com/0RGQEQ9.png\" alt=\"commit comment with the result of CO2\" width=\"768px\" /\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003ePR review\u003c/summary\u003e\n\n\u003cimg src=\"https://i.imgur.com/HiI2yCv.png\" alt=\"pull request comment/review with the result of CO2\" width=\"768px\" /\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eAction log\u003c/summary\u003e\n\n\u003cimg src=\"https://i.imgur.com/82BdVP6.png\" alt=\"action log with the result of CO2\" /\u003e\n\n\u003c/details\u003e\n\n#\n\n## Credits\n\nThis whole action is heavily inspired by the [Website Carbon Calculator](https://www.websitecarbon.com/) by [Wholegrain Digital](https://www.wholegraindigital.com/).\n\nThe renewable energy check is being done by [The Green Web Foundation](https://www.thegreenwebfoundation.org/).\n\nBoth of them support a great cause so consider supporting them:\n\n- https://www.wholegraindigital.com/#services\n- https://nlnet.nl/donating/ (I'm not sure how to donate to The Green Web Foundation, but this it the closest I could find)\n\nTake action: [Switch to a green host](https://www.wholegraindigital.com/blog/choose-a-green-web-host/) | [Make your website more efficient](https://www.wholegraindigital.com/blog/website-energy-efficiency/) | [Plant trees to reduce your carbon impact](https://treesforlife.org.uk/support/for-businesses/carbon-offsetting/)\n\n#\n\n## Contributing\n\n1. Read the [Code of Conduct](https://github.com/GeopJr/CO2/blob/main/CODE_OF_CONDUCT.md)\n2. Fork it ( https://github.com/GeopJr/CO2/fork )\n3. Create your feature branch (git checkout -b my-new-feature)\n4. Commit your changes (git commit -am 'Add some feature')\n5. Push to the branch (git push origin my-new-feature)\n6. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeopjr%2Fco2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeopjr%2Fco2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeopjr%2Fco2/lists"}