Alright I am gonna get straight to the point.
- Add 'app/src/main/res/values/secrets.xml' and 'app/src/main/res/values/secrets.xml~' in '.gitignore' file.
- Create 'secrets.xml' file in 'app/src/main/res/values' path.
- Add the following code in 'secrets.xml' :
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
<resources> <string name="API_KEY">YOUR_KEY_HERE</string> </resources> - Add the following code to your 'activity.kt' file:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
val secret = getString(R.string.API_KEY) - Add the following code under steps in your workflow file rite before build step:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
- name: Access Api keys env: apiKey: ${{ secrets.API_KEY }} path: app/src/main/res/values/secrets.xml run: | touch $path echo \<resources\> >> $path echo \<string name=\"API_KEY\"\>$apiKey\</string\> >> $path echo \</resources\> >> $path - Finally, add the secret to your GitHub repository with key “API_KEY”.
- That’s it. You are good to go.
Here's the example project:
Spotify Playlist Downloader
Top comments (0)