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

Support GITHUB_TOKEN provided by GitHub Actions #4176

Closed
nathany opened this issue Aug 22, 2019 · 10 comments · Fixed by #4225
Closed

Support GITHUB_TOKEN provided by GitHub Actions #4176

nathany opened this issue Aug 22, 2019 · 10 comments · Fixed by #4225

Comments

@nathany
Copy link

nathany commented Aug 22, 2019

  • Version: 21.2.0
  • Target: macOS

I'm attempting to build an Electron app using GitHub Actions. A GITHUB_TOKEN is provided which could possibly be used instead of creating a personal access token.

- name: Publish release
  run: npm run release
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

However, the following error occurs:

Error: GitHub Personal Access Token ("***") contains invalid characters, please check env "GH_TOKEN"
at new GitHubPublisher (/Users/runner/runners/2.157.0/work/tailboard-electron/tailboard-electron/node_modules/electron-publish/src/gitHubPublisher.ts:53:15)

@judge2020
Copy link
Contributor

I encoded it into hex to be able to extract the integration token from the output (they block base64-based exfiltration though) and the format is v1.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; the part after v1. is 40 characters long, the same length as regular personal access tokens. However, after some testing, you can't use this token without the v1. in front of it without getting 401 unauthorized.

The regex needs to be updated to allow the period.

return /^[\w\/=+-]+$/.test(token)

@judge2020
Copy link
Contributor

For a temporary, cross-platform fix, a step like this should allow the new token format to work. Since sed exits with code 0 even if no replacement occurred, this won't break when the PR is merged.

      - name: Temporarily fix electron-builder
        run: |
          sed -i 's/\^\[\\w/\^\[.\\w/g' node_modules/builder-util/out/util.js
        shell: bash

@nathany
Copy link
Author

nathany commented Sep 23, 2019

thanks

@stephan-nordnes-eriksen
Copy link

@judge2020 :

On MacOS you need the following syntax for sed to work

- name: Temporarily fix electron-builder
  run: |
    sed -i '' 's/\^\[\\w/\^\[.\\w/g' node_modules/builder-util/out/util.js
  shell: bash

@Stanzilla
Copy link

@develar can we get a release with that fix?

@samuelmeuli
Copy link

This is still happening with v21.2.0 (GitHub Actions on Ubuntu):

  ⨯ GitHub Personal Access Token ("***") contains invalid characters, please check env "GH_TOKEN"

samuelmeuli added a commit to samuelmeuli/mini-diary that referenced this issue Nov 30, 2019
Workaround required because `electron-builder` considers GitHub Actions tokens invalid: electron-userland/electron-builder#4176
@loopmode
Copy link

loopmode commented Dec 2, 2019

@samuelmeuli in https://github.com/samuelmeuli/mini-diary/blob/master/.github/workflows/release.yml#L48 you use a manual_github_token as a workaround - could you please explain what the value should be?
Is it simply what you create via https://github.com/settings/tokens/new?

@samuelmeuli
Copy link

@loopmode Yes, that's what I did for now

@samuelmeuli
Copy link

Ah, I see, the version that fixes this issue is not marked as stable yet, which is why it's not in my project. Running yarn add --dev electron-builder@^22.0.0 to get the beta should fix this then.

@0x77dev
Copy link

0x77dev commented Dec 12, 2019

The same issue here:

Error: GitHub Personal Access Token ("***") contains invalid characters, please check env "GH_TOKEN"
    at new GitHubPublisher (D:\a\classroom.server\classroom.server\node_modules\electron-publish\src\gitHubPublisher.ts:53:15)

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

Successfully merging a pull request may close this issue.

7 participants