Unable to generate password on GitHub Actions usin OP CLI tool

adi9090
adi9090
Community Member

I'm using OP CLI tool to generate passwords for automating the creation of .jks files for Android builds over GitHub Actions.
Locally I've created a script that is doing everything that is needed and it works flawlessly.
Command I'm executing: op item create --category=password --title="GeneratedPassword" --vault="Test" --generate-password='20,letters,digits'
This has been done locally on Ubuntu 20.04 LTS and GitHub Action is running the same version of OS.

Additionally, I've set the environment variable OP_DEBUG to true and only output after running above command I get is:
3:43PM | DEBUG | Skipped loading desktop app settings file. The desktop app might not be installed: read file: lstat /home/runner/.config/1Password/settings/settings.json: no such file or directory

Also, the OP_SECRET_KEY and OP_PASSWORD environment variables are defined on GitHub Action.

I don't know how to debug this issue as I don't get any valid output on why this has failed.


1Password Version: 2.7.3
Extension Version: Not Provided
OS Version: Ubuntu 22.04.1 LTS
Browser:_ Not Provided
Referrer: forum-search:github action create password

Comments

  • Nhat_Nguyen
    edited November 2022

    Hello @adi9090,
    From your descriptions, it seems 1Password couldn’t authenticate your credentials in GitHub Actions.
    For more information, 1Password CLI works on your computer because it can connect with the desktop app for authentication, but for it to run in GitHub Actions, we will need some additional commands to add your account manually.
    That said, let us try these steps under jobs to see if it works. I am running the latest macOS, but you can use the steps here to install 1Password on Ubuntu.

      env:
          EMAIL: ${{ secrets.EMAIL }}
          SECRET_KEY: ${{ secrets.SECRET_KEY }}
          PASSWORD: ${{ secrets.PASSWORD }}
        steps:
          - uses: actions/checkout@v3
          - name: install 1password
            run: brew install --cask 1password/tap/1password-cli
          - name: start op
            run: |
              eval $(echo “$PASSWORD” | op account add --address my.1password.com --email “$EMAIL” --secret-key “$SECRET_KEY”)
              eval $(echo “$PASSWORD” | op signin)
              op item create --category=password --title=“GeneratedPassword” --vault=“Test” --generate-password=’20,letters,digits
    
  • adi9090
    adi9090
    Community Member

    Hi @Nhat_Nguyen

    First sorry for the late reply, this got pushed lower with priority and I haven't noticed your reply.

    I've applied what you've suggested and now I'm getting invalid JSON error

    Error: 2023/03/29 19:53:11 Failed to create item: invalid JSON
    Error: Process completed with exit code 1.

  • Hi @adi9090,

    The code block above looks like it might be missing a ` at the end, if you add it does that work?

    Thanks,
    Amanda

This discussion has been closed.