Skip to content

Copy 1Password plain notes file into .envΒ #41

@whobutsb

Description

@whobutsb

Hello All,
I'm trying to deploy a Laravel application with a environment file saved in our 1Password vault as a secure note. In our github action we would like to use the latest copy of the environment file and add the contents to a .env during the deployment process. This is how we are currently doing it:

      - name: Configure 1Password Connect
        uses: 1password/load-secrets-action/configure@v1
        with:
          # Persist the 1Password Service Account token. This will grant
          # all steps of the job access to the token.
          service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}

      # Get ENV content from 1Password
      - name: Load secret
        id: op-load-secret
        uses: 1password/[email protected]
        with:
          export-env: true
        env:
          APP_ENV: "op://MyProject/Staging Environment/notesPlain"

      # Create ENV file
      - name: Copy the secret to .env
        run: 'echo $APP_ENV > .env'

When it gets to loading the .env file the contents of the file and error is message:

The environment file is invalid!
Failed to parse dotenv file. Encountered unexpected whitespace at ["Laravel Application" *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***].

Is there any way to unmask the contents?

In our local development process we have setup a Makefile command to help with downloading the latest environment file:

env-staging:
	op read op://$(ACCOUNT_NAME)/$(ENV_STAGING)/notesPlain -o .env.staging
         cp .env.staging .env

It would be great mimic the functionality of the Makefile command with this github action.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions