Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maarceloluiz/springboot-weather-forecast
A Spring Boot project that dynamically generates and updates weather forecasts using GitHub Actions, featuring hourly and multi-day forecast tables for easy embedding into GitHub profiles.
https://github.com/maarceloluiz/springboot-weather-forecast
actions api ci-cd docker java lombock maven spring-boot workflow
Last synced: 13 days ago
JSON representation
A Spring Boot project that dynamically generates and updates weather forecasts using GitHub Actions, featuring hourly and multi-day forecast tables for easy embedding into GitHub profiles.
- Host: GitHub
- URL: https://github.com/maarceloluiz/springboot-weather-forecast
- Owner: MaarceloLuiz
- License: mit
- Created: 2024-12-10T14:31:02.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-01-02T07:12:37.000Z (15 days ago)
- Last Synced: 2025-01-02T08:22:43.892Z (15 days ago)
- Topics: actions, api, ci-cd, docker, java, lombock, maven, spring-boot, workflow
- Language: Java
- Homepage: https://github.com/MaarceloLuiz/springboot-weather-forecast
- Size: 412 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: License
Awesome Lists containing this project
README
# 1- Hourly Forecast
## Today's Weather
`Dublin - 2025-01-03`
Sunny
Waxing Crescent
Hour
00:0001:0002:0003:0004:0005:0006:0007:0008:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:0019:0020:0021:0022:0023:00Weather
Condition
Clear Clear Clear Clear Clear Clear Clear MistClear SunnySunnySunnySunnySunnySunnyPartly Cloudy Partly Cloudy Clear Clear Partly Cloudy Partly Cloudy Clear Clear Clear Temperature
-2.0 °C-2.1 °C-2.1 °C-2.2 °C-2.2 °C-2.2 °C-2.2 °C-0.7 °C-2.2 °C-2.1 °C-0.4 °C2.0 °C3.0 °C3.7 °C3.7 °C3.1 °C0.8 °C-0.6 °C-0.7 °C-0.5 °C-0.4 °C-0.1 °C-0.1 °C-0.2 °CWind
10.1 kph10.8 kph11.2 kph12.2 kph13.0 kph14.0 kph14.8 kph15.1 kph14.8 kph14.8 kph14.4 kph14.8 kph14.8 kph14.0 kph13.3 kph12.6 kph12.2 kph11.5 kph10.8 kph10.8 kph10.1 kph9.0 kph8.6 kph7.6 kph*Updated at: 2025-01-03 07:12 by [MaarceloLuiz/springboot-weather-forecast](https://github.com/MaarceloLuiz/springboot-weather-forecast)*
# 2- Multi-Day Forecast
## 3 Days Weather Forecast
`Dublin - 2025-01-03`
Sunny
Waxing Crescent
Date
2025-01-032025-01-042025-01-05Weather
Condition
SunnyPatchy rain nearbyHeavy rainMoon Phase
Waxing CrescentWaxing CrescentWaxing CrescentMoon
Temperature
-2.2 - 3.7 °C-0.1 - 4.2 °C2.2 - 2.9 °CWind
15.1 kph26.3 kph36.7 kph*Updated at: 2025-01-03 07:12 by [MaarceloLuiz/springboot-weather-forecast](https://github.com/MaarceloLuiz/springboot-weather-forecast)*
---
# Weather Forecast
[![NPM](https://img.shields.io/npm/l/react)](https://github.com/MaarceloLuiz/springboot-weather-forecast/blob/main/License)## Objective
- Fetching accurate weather data from [WeatherAPI](https://www.weatherapi.com/).
- Updating forecasts automatically.
- Using a CI/CD pipeline for workflow automation.## Features
- Daily Updates: Automatically fetches and updates weather forecasts every day.
- GitHub Actions: Utilizes workflows to automate daily operations.
- Dockerized Environment: Provides a consistent runtime environment for builds and tests.
- Java Spring Boot: Implements the application's backend logic.
- Library Deployment with Repsy: [WeatherAPI](https://www.weatherapi.com/)'s library was deployed on Repsy, with the library also available on GitHub Packages.
- Customizable Forecast: Configurable for location, days and table style.## Technologies and Frameworks
- Programming Languages & Frameworks
- Java
- Spring Boot
- Maven (Build Tool)
- CI/CD & Automation
- GitHub Actions
- Workflow Configuration (action.yml)
- Containerization
- Docker---
# How to Use
## Step 1: Create an Account and Get an API Key- Visit [WeatherAPI](https://www.weatherapi.com/) and create a free account.
- After signing up, navigate to your account dashboard.
- Generate a new API key, which will be required for the application to fetch weather data.
- Save this API key securely, as you’ll need it in the next steps.## Step 2: Embed the Tables in Any Repository
You can embed the generated tables into any repository, including your GitHub profile repository. Follow these steps:- If you haven’t already, create a repository named / (e.g., github.com/yourusername/yourusername). This will automatically act as your GitHub profile's README.md.
- Insert the following placeholders into your README.md file exactly as shown below. Place the placeholders in the specific location where you want the table to appear.
```bash```
These placeholders are required for the workflow to identify where to embed the forecast tables. **Make sure the placeholders match exactly as shown above**, including the casing and dashes.
- \, \ : These placeholders will embed the [**hourly table**](https://github.com/MaarceloLuiz/springboot-weather-forecast#1--hourly-forecast), in case you choose this option in the workflow configuration.
- \, \ : These placeholders will embed the [**multi-day table**](https://github.com/MaarceloLuiz/springboot-weather-forecast#2--multi-day-forecast), in case you choose this option in the workflow configuration.**Why should you add both placeholders?**
- Flexibility: If you only choose one table type now, the other placeholder will simply remain empty and won't impact your workflow or file appearance.
- Even if you only choose one table type (e.g., hourly), the workflow will ignore unused placeholders. You can later update the TABLE_TYPE variable to include other table types (e.g., multi-day or both) without modifying your README.md file.## Step 3: Set Up Environment Variables
**Configuration and Environment Variables**
To add Secrets and Variables:, follow these steps **carefully**:- Navigate to your repository on GitHub.
- Go to **Settings > Secrets and variables > Actions**.
- Under the **Secrets** tab, click **New Repository Secret** and add the following **exactly as shown**:
- ``` WEATHER_API_KEY ```: Your API key from WeatherAPI.
- Under the **Variables** tab, click **New Repository Variable** and add the following variables **exactly as shown**:
- ``` FORECAST_CITY ```: The city for which you want the weather forecast (e.g., Dublin).
- ``` FORECAST_DAYS ```: Number of days to forecast (e.g., 3 for a 3-day forecast).
- ``` TABLE_TYPE ```: The type of forecast table. **Choose ONE of the following options**:
- ``` hourly ``` : For hourly forecasts. -> [**hourly table example**](https://github.com/MaarceloLuiz/springboot-weather-forecast#1--hourly-forecast)
- ``` multi-day ``` : For multi-day forecasts. -> [**multi-day table example**](https://github.com/MaarceloLuiz/springboot-weather-forecast#2--multi-day-forecast)
- ``` both ``` : For both hourly and multi-day forecasts.⚠️ **Important:** Ensure the variable names (``` WEATHER_API_KEY ```, ``` FORECAST_CITY ``` , ``` FORECAST_DAYS ```, ``` TABLE_TYPE``` ) are entered exactly as shown above, including capitalization.
## Step 4: Set Up the GitHub Workflow
- To create a folder in your repository called .github/workflows/. follow the instructions:
- Navigate to the **Actions** tab in your repository.
- Under **"Simple workflow"**, click **"Configure"**.
- Rename the default workflow file to *update-weather.yml* or *update-readme.yml* for clarity.
- Copy and paste the following workflow code into the file:
```bash
name: "Update Weather"on:
workflow_dispatch:
schedule:
- cron: "0 9 * * *"
jobs:
run-weather-app:
runs-on: ubuntu-latest
timeout-minutes: 10steps:
- name: Check out repository
uses: actions/checkout@v3- name: Run Action
uses: MaarceloLuiz/[email protected]
with:
WEATHER_API_KEY: ${{ secrets.WEATHER_API_KEY }}
FORECAST_CITY: ${{ vars.FORECAST_CITY }}
FORECAST_DAYS: ${{ vars.FORECAST_DAYS }}
TABLE_TYPE: ${{ vars.TABLE_TYPE }}- name: Commit and Push Changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add README.md
git commit -m "Update weather forecast" || echo "No changes to commit"
git push origin main
```**Workflow Explanation:**
- ``` cron: "0 9 * * *" ``` -> Runs automatically every day at 9:00 AM UTC.
- *MaarceloLuiz/[email protected]* -> Executes the custom GitHub action that generates the weather forecast tables.
- It uses the input you defined before:
- **WEATHER_API_KEY, FORECAST_CITY, FORECAST_DAYS, TABLE_TYPE.**
- Commit and Push Changes:
- Stages the updated README.md file and commits the changes with the message: Update weather forecast.
- Pushes the changes to the main branch of the repository and includes a fallback (*|| echo "No changes to commit"*) in case there are no updates to the forecast tables.
## Step 5: Ensure your Workflow has permission to push changes to your repository
- Go to your repository settings:
- Settings > Actions > General
- Under Workflow permissions, select:
- **Read and write permissions**
- Click **Save**.## Step 6: Run the Workflow or Let it Run Automatically
- Manually Run the Workflow:
- Go to the **Actions** tab in your repository.
- Find the **"Update Weather"** workflow in the list.
- Click **"Run workflow"** to test it immediately.
- Automatically Run the Workflow:
- The workflow is set to run daily at 9:00 AM UTC based on the schedule defined in the cron configuration.
- Check the Results:
- Once the workflow completes, check your README.md file in the repository.