{"id":18625518,"url":"https://github.com/nprapps/bernard","last_synced_at":"2025-04-11T04:32:34.582Z","repository":{"id":147503997,"uuid":"79957628","full_name":"nprapps/bernard","owner":"nprapps","description":"A Slack incoming webhook setup as a cron job that retrieves all new rules, proposed rules, and presidential documents from the Federal Register","archived":false,"fork":false,"pushed_at":"2017-01-25T15:56:56.000Z","size":10,"stargazers_count":10,"open_issues_count":2,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-25T09:46:44.933Z","etag":null,"topics":["cron","federal-government","slack"],"latest_commit_sha":null,"homepage":"","language":"Python","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/nprapps.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":"2017-01-24T21:46:07.000Z","updated_at":"2025-03-13T15:28:42.000Z","dependencies_parsed_at":"2023-06-07T22:15:42.752Z","dependency_job_id":null,"html_url":"https://github.com/nprapps/bernard","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/nprapps%2Fbernard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nprapps%2Fbernard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nprapps%2Fbernard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nprapps%2Fbernard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nprapps","download_url":"https://codeload.github.com/nprapps/bernard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345202,"owners_count":21088231,"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":["cron","federal-government","slack"],"created_at":"2024-11-07T04:34:48.427Z","updated_at":"2025-04-11T04:32:34.526Z","avatar_url":"https://github.com/nprapps.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bernard\n\n## What is this?\n\n**Bernard is a Slack incoming webhook setup as a cron job that retrieves all new rules, proposed rules, and presidential documents from the Federal Register. This repo will provide the infrastructure to setup a cron job on an Ubuntu server.**\n\nIt is named after Bernard Kennedy, the first director of the Federal Register.\n\n## Assumptions\n\nThe following things are assumed to be true in this documentation.\n\n* You are using Python 2.7.\n* You have [virtualenv](https://pypi.python.org/pypi/virtualenv) and [virtualenvwrapper](https://pypi.python.org/pypi/virtualenvwrapper) installed and working.\n\nFor more details our stack, see our [development environment blog post](http://blog.apps.npr.org/2013/06/06/how-to-setup-a-developers-environment.html).\n\n## What's in here?\n\nThe project contains the following folders and important files:\n\n* ``fabfile`` -- [Fabric](http://docs.fabfile.org/en/latest/) commands for automating setup, deployment, data processing, etc.\n* ``app_config.py`` -- Global project configuration for scripts, deployment, etc.\n* ``crontab`` -- Cron jobs to be installed as part of the project.\n* ``requirements.txt`` -- Python requirements.\n* ``run_on_server.sh`` -- Shell script to run at the beginning of cron jobs to source environment variables and virtual environments.\n\n## Bootstrap the project\n\n```\ncd bernard\nmkvirtualenv bernard\npip install -r requirements.txt\n```\n\n## Hide project secrets\n\nProject secrets should **never** be stored in ``app_config.py`` or anywhere else in the repository. Instead, always store passwords, keys, etc. in environment variables and document that they are needed here in the README.\n\nAny environment variable that starts with ``$PROJECT_SLUG_`` will be automatically loaded when ``app_config.get_secrets()`` is called.\n\n## Connecting to Slack\n\nTo connect Bernard to your Slack, you will need to create an [incoming webhook](https://api.slack.com/incoming-webhooks) and copy the webhook endpoint to an environment variable called `bernard_WEBHOOK`.\n\n## Deploy to EC2\n\n1. Run ``fab staging master servers.setup`` to configure the server.\n2. Run ``fab staging master deploy`` to deploy the project to the server. Note that this will also install your crontab.\n\n## Managing cron jobs\n\nCron jobs are defined in the file `crontab`. Each task should use the `run_on_server.sh` shim to ensure the project's virtualenv is properly activated prior to execution. For example:\n\n```\n* * * * * ubuntu bash /home/ubuntu/apps/bernard/repository/cron.sh fab $DEPLOYMENT_TARGET cron_jobs.test \u003e\u003e /var/log/bernard/crontab.log 2\u003e\u00261\n```\n\nThe cron jobs themselves should be defined in `fabfile/cron_jobs.py` whenever possible.\n\nTo install the cronjob, run either `fab staging master deploy`, which will also synchronize the repo with the latest on Github, or `fab staging master servers.install_crontab` to simply copy the crontab on the server to `etc/cron.d`.\n\nTo uninstall the cronjob (a recommended practice for disabling the job), run `fab staging master servers.uninstall_cronjob`.\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnprapps%2Fbernard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnprapps%2Fbernard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnprapps%2Fbernard/lists"}