I'm trying to run an action that requires JSONs for authentication within my R Script.
I have stored these two JSON as Github Secrets Action:
GMAIL_ADDRESS
GMAIL_SECRET_API
This is my main.yml section that calls these two JSONs
# Run R script
- name: execute r script # email-from-r.R
env:
GMAIL_SERVICE: ${{ secrets.GMAIL_SECRET_API }}
GMAIL_ADDRESS: ${{ secrets.GMAIL_ADDRESS }}
run: Rscript mailer.R
And in my script I'm recalling these two files with this:
GMAIL_SERVICE <- Sys.getenv("GMAIL_SECRET_API")
GMAIL_ADDRESS <- Sys.getenv("GMAIL_ADDRESS")
The workflow runs but returns this error:
Error: Error: Must supply either `key` and `secret` or `path`
Execution halted
Error: Process completed with exit code 1.
I'm quite sure that the problem is that I'm not getting the two JSONs correctly from the Secrets.
Here is my full code for the script:
library(gmailr)
library(googleAnalyticsR)
library(googledrive)
library(lubridate)
library(scales)
library(tidyverse)
library(gt)
library(googleAuthR)
GMAIL_SERVICE <- Sys.getenv("GMAIL_SECRET_API")
GMAIL_ADDRESS <- Sys.getenv("GMAIL_ADDRESS")
gmailr::gm_auth_configure(path = GMAIL_SERVICE ,
appname = "gmailr")
gmailr::gm_auth(email = GMAIL_ADDRESS,
path = GMAIL_SERVICE,
scopes = "full")
TEST <-
gm_mime() %>%
gm_to(c(GMAIL_ADDRESS)) %>%
gm_from(GMAIL_ADDRESS) %>%
gm_subject(paste0("TEEEEEEEEEST", "BOOOOOOM", "-", "TEEEEEST")) %>%
gm_text_body("TEEEEEEEST")
gm_send_message(TEST)
date <- gm_date(TEST)
date_2 <- Sys.time()
log <- paste0("The mail has been successfully sent on: ", date)
write.csv(log, file = paste0("data/Log_", date_2, ".csv"))