canovasjm / covid-19-san-juan

MIT License
11 stars 11 forks source link

Please Help me solve this #1

Closed LaxmanMaharjan closed 3 years ago

LaxmanMaharjan commented 3 years ago

This is python file import smtplib import os from email.message import EmailMessage

EMAIL_ADDRESS = os.environ.get('EMAIL_ADDRESS') EMAIL_PASSWORD = os.environ.get('EMAIL_PASSWORD')

msg = EmailMessage() msg['Subject'] = 'Checking smtplib FROM GITHUB' msg['From'] = EMAIL_ADDRESS msg['To'] = 'lxmnmrzn@gmail.com'

msg.set_content('This is a email check.')

with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD) smtp.send_message(msg)

This is .yml file name: CI

on:

push: branches: [ master ] pull_request: branches: [ master ] schedule:

jobs:

build:

runs-on: ubuntu-latest

steps:

  - uses: actions/checkout@v2

  - name: setup python
    uses: actions/setup-python@v2
    with:
      python-version: '3.7'

  - name: execute py script 
    env: 
      EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }}
      EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}

    run: python send_email.py

This error comes while running python file in github actions TypeError: can only concatenate str (not "bytes") to str

canovasjm commented 3 years ago

Apparently, the .yml workflow is running correctly and the error seems to be in the python code. Have you properly set up the GitHub secrets EMAIL_ADDRESS and EMAIL_PASSWORD ?

LaxmanMaharjan commented 3 years ago

I think I did it properly Took Reference from your blog

On Sun, Apr 25, 2021, 9:59 PM canovasjm @.*** wrote:

Apparently, the .yml workflow is running correctly and the error seems to be in the python code. Have you properly set up the GitHub secrets EMAIL_ADDRESS and EMAIL_PASSWORD ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/canovasjm/covid-19-san-juan/issues/1#issuecomment-826349282, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN2DWP4KMWMQJSC3Q6ODLP3TKQ5VRANCNFSM43RBGAMQ .

LaxmanMaharjan commented 3 years ago

smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD) TypeError: can only concatenate str (not "bytes") to str I can't understand why this error appears even though EMAIL_ADDRESS and EMAIL_PASSWORD are both str type

canovasjm commented 3 years ago

I think there is still an issue with the GitHub secrets, from what I see in the log from your failed run. You can check it as follows:

1) Go to your repo 2) Go to the "Actions" tab 3) Select the failed run 4) Select "build" under jobs 5) Unfold "execute py script" 6) Unfold "Run python send email" 7) Check the secrets' name under env:

image

The successful log for mi repository looks as follows:

image

You can see mine has three stars *** , indicating that something is being read there. This is not the case for your workflow.

LaxmanMaharjan commented 3 years ago

Yes Thank you so much There was an issue with the GitHub secrets, was setting secrets in environment instead of repo. Thank you for help means a lot.

canovasjm commented 3 years ago

I'm glad it helped! :)