noloman
noloman

Reputation: 11975

Keeping local changes after git Untracked Files Prevent Merge

I have an Android app in GitHub which uses an API key. I have set it up in my local.properties and ignored it in gitignore.
However, in order for GitHub Actions to build my app, it looks for a local.properties file with a certain key, and as it is ignored, the build process fails. I created a fake local.properties in GitHub with an empty key and it works (the tests don't need to see the map itself, but they just need the app to compile and run), but unfortunately, whenever I try to pull from the remote, I get:

error: The following untracked working tree files would be overwritten by merge:
    local.properties

Of course, I want to keep the local copy of local.properties as it is the one that contains the valid API key.

What can I do in order to prevent this, so I can be able to push and pull, and have the project built but without exposing my keys?

Thanks!

Upvotes: 3

Views: 244

Answers (1)

peterevans
peterevans

Reputation: 41990

Why not create the fake local.properties file in your workflow instead of committing it. Then it will only exist temporarily.

      - name: Create local.properties
        run: echo "apikey=empty" > local.properties

Alternatively, commit a file with a different name and rename it just before building.

      - name: Create local.properties
        run: mv local.properties.fake local.properties

Upvotes: 3

Related Questions