Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Action incorrectly getting value from weather-api-key parameter specified in with attribute #3

Open
TailonR opened this issue Sep 9, 2024 · 0 comments

Comments

@TailonR
Copy link

TailonR commented Sep 9, 2024

I added the instructions for invoking the Github Action to my workflow, which is triggered by a workflow_dispatch. When I run the workflow it fails an error from main.py saying it can't find the key "name" in api_data_json. There is a line right above that error saying 401 Client Error: Unauthorized for url: https://api.openweathermap.org/data/2.5/weather?id=5506956&units=imperial&mod=json&appid=***%20 What this looks like to me is that a space is being appended to my api key which makes the api key incorrect and so the data being sent back isn't what the Action is expecting.

- name: Get Weather using OpenWeather 
uses: bumb7ebee/[email protected]
with:
  # OpenWeather API key
  weather-api-key: ${{ secrets.WEATHER_API_KEY }}
  # City ID obtained from OpenWeather
  city-id: ${{ github.event.inputs.city-id }}
  # Centigrade (c) or Fahrenheit (f)
  units: f
  # Country code obtained from https://flagicons.lipis.dev/
  country-code: um
  # README.md file path
  readme-path: ./weather_report.md

This is how I invoke your Action in my workflow.

Attached is the logs associated with the error.
Screenshot 2024-09-09 090208

Steps to reproduce

  1. Obtain a secret key form Open Weather and add it to your repository secrets in the Actions tab.

  2. Create a workflow in .github/workflows giving it a name. Make sure the workflow is triggered by workflow_dispatch and give it an input with the name "city-id"

name: Get Weather Data

on: 
  workflow_dispatch:
    inputs:
      city-id:
        required: true
        description: Enter id of a U.S city (found on openweathermap.org)
  1. Add the instructions for invoking the workflow
  weather-action:
    name: Get Weather Data
    runs-on: ubuntu-latest

      - name: Get Weather using OpenWeather 
        uses: bumb7ebee/[email protected]
        with:
          # OpenWeather API key
          weather-api-key: ${{ secrets.WEATHER_API_KEY }}
          # City ID obtained from OpenWeather
          city-id: ${{ github.event.inputs.city-id }}
          # Centigrade (c) or Fahrenheit (f)
          units: f
          # Country code obtained from https://flagicons.lipis.dev/
          country-code: um
          # README.md file path
          readme-path: ./weather_report.md
  1. Push the code to Github and then go to the Actions tab, select the new workflow, then click the Run workflow drop down.

  2. Enter a city id and then click "run workflow"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant