Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/coding-to-music/github-actions-cron-readme-weather-api

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/coding-to-music/github-actions-cron-readme-weather-api

  • v1.0.1
  • Source
  • Go
  • Socket score

Version published
Created
Source

Today's Weather

Boston, United States of America - 15/09/2023

Overcast

Hour00: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
ConditionOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastOvercastCloudyPartly cloudySunnySunnyPartly cloudyCloudyOvercastOvercastPartly cloudy
Temperature16.9 °C16.7 °C16.5 °C16.3 °C16.1 °C15.6 °C15.6 °C15.6 °C15.8 °C16.3 °C16.4 °C17.3 °C17.7 °C18.3 °C19.4 °C20.8 °C22.5 °C23 °C22.5 °C20.6 °C18.9 °C18.4 °C18 °C18.9 °C
Wind24.8 kph25.2 kph25.9 kph26.6 kph26.3 kph26.3 kph22.3 kph19.4 kph18.7 kph20.5 kph23.8 kph31.3 kph33.1 kph30.2 kph27 kph24.8 kph25.9 kph24.1 kph23.4 kph22.7 kph20.5 kph19.1 kph18 kph24.1 kph

Weather For Next 7 days

Date15/09/202316/09/202317/09/202318/09/202319/09/202320/09/202321/09/2023
Weather
ConditionOvercastSunnyHeavy rainModerate rainSunnySunnySunny
Temperature15.6 - 23 °C14 - 26.4 °C15.9 - 17.7 °C13.5 - 22.7 °C10.7 - 20.9 °C11.2 - 19.8 °C11.7 - 19.1 °C
Wind33.1 kph17.6 kph14 kph23 kph14 kph11.2 kph11.9 kph

Updated at: 2023-09-16T04:08:43Z

GitHub Actions: Embed up-to-date Weather in your README

View

You can easily embed tables in your README.md using GitHub Actions by following these simple steps:

Step 1: In your repository, create a file named README.md.template.

Step 2: Write anything you want within the README.md.template file.

Step 3: Embed one of the following entities within your README.md.template:

  • Today's Weather Table:
{{ template "hourly-table" $.TodayWeather.HourlyWeathers }}
  • Daily Weather Table:
{{ template "daily-table" .Weathers }}
  • Updated at:
{{ formatTime .UpdatedAt }}

If you are familiar with Go templates, you have access to the root variable, which includes the following fields:

  • Weathers: An array of daily Weather. You can view the Weather struct definition in model/weather.go.
  • UpdatedAt: This field contains the timestamp in the format of time.Date.

Step 4: Register Github Action

  • Create a file .github/workflows/update-weather.yml in your repository.
name: "Cronjob"
on:
schedule:
  - cron: "15 * * * *"

jobs:
  update-weather:
    permissions: write-all
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Generate README
        uses: coding-to-music/github-actions-cron-readme-weather-api@v1.0.5
        with:
          city: HaNoi
          days: 7
          weather-api-key: ${{ secrets.WEATHER_API_KEY }}
          template-file: "README.md.template"
          out-file: "README.md"
      - name: Commit
        run: |
          if git diff --exit-code; then
            echo "No changes to commit."
            exit 0
          else
            git config user.name github-actions
            git config user.email github-actions@github.com
            git add .
            git commit -m "update"
            git push origin main
          fi
  • Update some variable in this file:
    • city: The city that you want to forecast weather
    • days: number of forecast days
    • template-file: Path to the above template file. Eg. template/README.md.template
    • out-file: your README.md file name
    • weather-api-key:
      • Register free API key in https://weatherapi.com
      • Setup secrets with name WEATHER_API_KEY in Your repo > settings > Secrets and variables > Actions > New repository secret

Step 5: Commit your change, then Github actions will run as your specificed cron to update Weather into your README.md file

Usage

View
Install
go install https://github.com/coding-to-music/github-actions-cron-readme-weather-api
Run
Usage:
weather-forecast update-weather [flags]

Flags:
--city string              City
--days int                 Days of forecast (default 7)
-h, --help                     help for update-weather
-o, --out-file string          Output file path
-f, --template-file string     Readme template file path
-k, --weather-api-key string   weatherapi.com API key

Sample

weather-forecast update-weather \
--days=7 \
--weather-api-key="$WEATHER_API_KEY" \
--template-file='template/README.md.template' \
--city=HaNoi \
--out-file='README.md'

Docker

docker run --rm \
-v ./:/app/data \
weather-forecast \
--weather-api-key='XXXX' \
--city=HaNoi \
--out-file=data/README.md \
--template-file=data/README.md.template

FAQs

Package last updated on 17 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc