Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 2.71 KB

README.md

File metadata and controls

47 lines (33 loc) · 2.71 KB

project-watertemp

The goal of this project is to scrape and accumulate data on Hungarian natural water (rivers, lakes) temperatures.

Setup

  • Run make in your terminal to see and run most available commands.
  • Run make init-githook once at the beginning (and each time a hook is added to /.githooks.)
  • Run make build, then
  • run make build-dev to build the base and the development image
  • Press cmd + shift + p and type "reopen in container" and select the first item from the dropdown list. This will launch VSCode's 'Dev Container'. VSC will now reload within a Docker container originated from the development image that you've just built.
    • All VSC functionalities, such as the terminal, tests, debugging, etc. will use the dev container's resources.

Heroku

  • service name in heroku.yml must be web
  • web service dynos can be scaled down to 0 for the scheduler and on-off runs to operate
  • set your Heroku stack to 'container': heroku stack:set container -a water-temp
  • Inspect the env vars set on Heroku: heroku config -a water-temp

CI/CD

  • On commit, the .githooks/pre-commit script will run make test. If it fails, the commit will fail too
  • On push, a Github Action CI will trigger which is configured in .github/workflows/workflow.yml
  • Note, CI will only trigger when a file listed in .github/workflows/workflow.yml under paths changes. Source.
  • Github Actions is configured to test and then to push the prod and dev image to Heroku's registry, finally to deploy the prod image into production
  • Add [skip ci] to the commit message to skip CI (e.g. when only modifying this README). Source.

Dev. resources

Useful Postgre (PG) CLI commands

  • make run-psql or make run-psql-heroku will start up the PG cli (run it outside of the dev docker container)
  • \d will list your tables
  • SELECT: select * from water_temp_unique limit 10;
  • DELETE: delete from water_temp_unique where location in ('Szelidi-tó')

How to log in from Github Actions (docker) to Heroku?

  • This is done via a Heroku api token
  • First, log in to Heroku from the terminal (heroku login)
  • A long-lived token was generated using heroku authorizations:create
  • Check all your tokens by typing heroku authorizations
  • Add the token (see output of the above create command) to the Github secret HEROKU_API_KEY. Find it under the Github repo > settings > secrets.