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

Unable to use clasp run in Github actions workflow #962

Closed
jaemin-capslock opened this issue May 1, 2023 · 4 comments
Closed

Unable to use clasp run in Github actions workflow #962

jaemin-capslock opened this issue May 1, 2023 · 4 comments

Comments

@jaemin-capslock
Copy link

(Note: Non-breaking issues are likely not to be prioritized. Please consider a PR in addition to your issue)

Expected Behavior

I have a function in my code that runs tests of my code. Currently, I want to use GitHub actions to do the following workflow:

Github push -> install clasp in GitHub actions -> clasp login --creds creds.json -> clasp run runTests -> clasp push

According to run.md, it is necessary to run the clasp login step to use clasp run. clasp login returns an OAuth URL to the terminal which the user has to manually click and verify, which is not possible within Github actions. Are there any workarounds or suggestions?

@sanmisanti
Copy link

Have you found any solutions?

@sqrrrl
Copy link
Member

sqrrrl commented Jan 7, 2025

You can use clasp in github workflows, see https://github.com/googleworkspace/apps-script-samples/blob/main/.github/workflows/publish.yaml#L36 as an example.

  1. Locally authorize clasp with the intended account.
  2. Copy .clasprc.json to a github secret
  3. Write the secret back to .clasprc.json in the workflow before calling clasp.

Service accounts aren't currently support with clasp, not sure if ever will as apps script isn't intended to be used by them.

@pkit
Copy link

pkit commented Jan 8, 2025

@sqrrrl the secret will expire in 6 month. Unless it's updated. I.e. either deploys will stop working exactly on the day of fire or you need to give full admin access to the github action to update secret dynamically.
I.e. it's not a solution.

@sqrrrl
Copy link
Member

sqrrrl commented Jan 17, 2025

Will track as part of #950. Investigating to see if can support service accounts in 3.x, need to do some experiments.

Closing as duplicate.

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

Successfully merging a pull request may close this issue.

4 participants