mrkaye97 / slackr

An R package for sending messages from R to Slack
https://matthewrkaye.com/slackr/
Other
307 stars 83 forks source link

Wondering about using slackr environment variables with Github Actions #175

Closed invisibae closed 2 years ago

invisibae commented 2 years ago

Hi!

I am trying to automate my slackr posts through Github Actions and I have a question:

Was trying to run an R script that included slackr through a github aciton and I keep running into a problem where my script runs without any errors but fails to post to slack because while the requisite environment variables ('SLACK_CHANNEL', 'SLACK_TOKEN', 'SLACK_USERNAME', etc.) are present in the action environment, they're all unfortunately blank.

It was my understanding that I could set up environment variables ahead of time through Actions Secrets, call the env and specify the variables in my yaml script, and simply use slackr() along with Sys.getenv() to point the script to my env variables rather than using slackr_setup and exposing my API key.

While I'm encouraged by the fact that R seems to be seeing the env variables I set up through Action secrets, I am still unsure about why R thinks they are blank. Could it be that I am declaring the environment at the wrong point in the yaml file? Is R simply incompatible with Actions Secrets? Something else?

Screen Shot 2022-05-02 at 8 22 49 AM
mrkaye97 commented 2 years ago

Hey, thanks for putting in the issue. FYI, this isn't actually a slackr issue -- AFAICT you jut have your CI config or the secrets set up incorrectly. You can see how we did it for `slackr. It's tough for me to tell what the actual problem is, but my suspicion is that the secrets are defined as blank strings. In our CI runs, you can see env vars printed like this: https://github.com/mrkaye97/slackr/runs/5612881932?check_suite_focus=true#step:9:8

invisibae commented 2 years ago

Any advice on what might've gone wrong in CI config? I went back and double checked my environment secrets to make sure they weren't blank and I'm kind of at a loss. My next move will probably be to try to work backwards from your template, but I'm just trying to figure out where I went wrong here.

invisibae commented 2 years ago

NVM!