Skip to content

Latest commit

 

History

History
227 lines (175 loc) · 16 KB

README.md

File metadata and controls

227 lines (175 loc) · 16 KB

1- Hourly Forecast

Today's Weather

Dublin - 2025-02-10

Weather Condition Icon

Patchy rain nearby

Moon Phase Icon

Waxing Gibbous

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:00
Weather Weather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition IconWeather Condition Icon
Condition Patchy rain nearbyPatchy rain nearbyPatchy rain nearbyPatchy rain nearbyPatchy rain nearbyPatchy rain nearbyPatchy rain nearbyPartly cloudyPatchy rain nearbyPatchy rain nearbyPatchy rain nearbyLight sleet showersLight sleet showersLight sleet showersLight sleet showersLight sleet showersPatchy rain nearbyPatchy rain nearbyLight sleet showersPatchy rain nearbyLight sleet showersLight sleet showersLight rain showerLight rain shower
Temperature 5.6 °C5.5 °C5.4 °C5.3 °C5.2 °C4.8 °C4.6 °C5.1 °C4.4 °C4.5 °C4.8 °C4.8 °C4.8 °C4.7 °C4.6 °C4.5 °C4.4 °C4.2 °C4.3 °C4.3 °C4.2 °C4.3 °C4.4 °C4.2 °C
Wind 23.0 kph24.1 kph23.8 kph25.6 kph27.4 kph28.8 kph27.4 kph27.0 kph26.3 kph27.4 kph27.7 kph27.7 kph27.4 kph25.9 kph24.1 kph23.8 kph23.8 kph23.4 kph24.1 kph23.8 kph22.0 kph20.9 kph20.2 kph20.9 kph

Updated at: 2025-02-10 07:13 by MaarceloLuiz/springboot-weather-forecast

2- Multi-Day Forecast

3 Days Weather Forecast

Dublin - 2025-02-10

Weather Condition Icon

Patchy rain nearby

Moon Phase Icon

Waxing Gibbous

Date 2025-02-102025-02-112025-02-12
Weather Weather Condition IconWeather Condition IconWeather Condition Icon
Condition Patchy rain nearbyPatchy rain nearbyPatchy rain nearby
Moon Phase Waxing GibbousWaxing GibbousFull Moon
Moon Moon Phase IconMoon Phase IconMoon Phase Icon
Temperature 4.2 - 4.8 °C3.7 - 5.1 °C4.0 - 4.8 °C
Wind 28.8 kph20.2 kph17.6 kph

Updated at: 2025-02-10 07:13 by MaarceloLuiz/springboot-weather-forecast


Weather Forecast

NPM

Objective

  • Fetching accurate weather data from WeatherAPI.
  • 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'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 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.
<!-- HOURLY-START -->
<!-- HOURLY-END -->

<!-- MULTI-DAY-START -->
<!-- MULTI-DAY-END -->

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.

  • <!-- HOURLY-START -->, <!-- HOURLY-END --> : These placeholders will embed the hourly table, in case you choose this option in the workflow configuration.
  • <!-- MULTI-DAY-START -->, <!-- MULTI-DAY-END --> : These placeholders will embed the multi-day table, 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:

⚠️ 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:
name: "Update Weather"

on:
  workflow_dispatch:
  schedule:
    - cron: "0 9 * * *" 
  
jobs:
  run-weather-app:
    runs-on: ubuntu-latest
    timeout-minutes: 10

    steps:
      - name: Check out repository
        uses: actions/checkout@v3

      - name: Run Action
        uses: MaarceloLuiz/springboot-weather-forecast@v1.0.2
        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 "github-actions@github.com"
          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/springboot-weather-forecast@v1.0.2 -> 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.