Learning Project: A command-line tool to fetch weather data from Weather API for a Public Location. and convert it to different output formats.
Project based on this repo
This project gets also includes a CI/CD pipeline using GitHub actions and pushes the Docker Image to Docker Hub.
- Golang 1.17 or higher
- A CDO API token (you can get one for free from https://www.ncdc.noaa.gov/cdo-web/)
- DockerHub Account
- Github Actions
-
Clone this repository to your local machine:
git clone https://github.com/GuenadeSilva/WeatherCLI.git cd weathercli
-
Install necessary dependencies
go mod tidy
In order to connect to CDO API set up a .env
file int the project directory with following variable:
CDO_TOKEN=token
In order to use the CI/CD Pipeline ensure you create:
- DockerHub Account
- Create Personal Access Token
- Add them to the Repo's Secrets
Run the following command to see the available options:
go run main.go [flags]
Flags:
-csv: Enable CSV output (default: false)
-json: Enable JSON output (default: false)
Example usage:
go run main.go -csv -json
To use CI/CD Pipeline make sure you have the requiremens mentioned in the [Configuration](#configuration) then:
- Run this command to build a development image:
docker build -t weathercli:dev .
- To run the image use:
docker run --rm weathercli:dev
- To build the image locally for production:
docker build -t weathercli:1.0.0 . --build-arg VERSION=1.0.0
-
After that push the changes to "branch-name"
-
Check if the Tests ran properly, and if not fix them.
-
Run these final commands to push these to run final tests and push to DockerHub
git tag v1.0.0
git push --tags
This project is licensed under the MIT License.