How to inject github secrets in application.properties file of Spring boot application?

Viewed 99

How can I inject a GitHub secret in the application.properties file of a Spring-Boot application before the execution of build and deploy?

This is my current YAML file:

name: Heroku deployment

on:
  push:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Deploy to Heroku
      uses: AkhileshNS/heroku-deploy@v3.12.12
      with:
        heroku_api_key: ${{secrets.HEROKU_API_KEY}}
        heroku_email: ${{secrets.HEROKU_EMAIL}}
        heroku_app_name: event-handler

This is my application.properties file:

spring.datasource.url=
spring.datasource.username=
spring.datasource.password=

I currently inject some environmental variables to handle Heroku deployment, I would like to update my YAML file so as to inject also the values of database properties from GitHub secrets. Is it possible to do it using a similar approach? The attempt to align the YAML file as if it was an application.properties did not work, it seems not quite right.

0 Answers
Related