File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -29,12 +29,21 @@ jobs:
2929 java-version : ${{ matrix.java-version }}
3030 distribution : " adopt"
3131 cache : " gradle"
32-
32+
3333 - name : Replace secrets in application.properties
3434 run : |
35- sed -i "s#\\\$\\{DB_CONN_STR\\}#${{ vars.DB_CONN_STR }}#g" src/main/resources/application.properties
36- sed -i "s#\\\$\\{DB_USERNAME\\}#${{ vars.DB_USERNAME }}#g" src/main/resources/application.properties
37- sed -i "s#\\\$\\{DB_PASSWORD\\}#${{ secrets.DB_PASSWORD }}#g" src/main/resources/application.properties
35+ # Get the secret values and escape special characters
36+ escaped_conn_str=$(printf '%s\n' "${{ vars.DB_CONN_STR }}" | sed -e 's/[]\/$*.^[]/\\&/g')
37+ escaped_username=$(printf '%s\n' "${{ vars.DB_USERNAME }}" | sed -e 's/[]\/$*.^[]/\\&/g')
38+ escaped_secret_value=$(printf '%s\n' "${{ secrets.DB_PASSWORD }}" | sed -e 's/[]\/$*.^[]/\\&/g')
39+
40+ # Replace placeholders in application.properties
41+ sed -i "s/DB_CONN_STR/${escaped_conn_str}/g" ./src/main/resources/application.properties
42+ sed -i "s/DB_USERNAME/${escaped_username}/g" ./src/main/resources/application.properties
43+ sed -i "s/DB_PASSWORD/${escaped_secret_value}/g" ./src/main/resources/application.properties
44+
45+ # Print the updated file for verification
46+ cat ./src/main/resources/application.properties
3847 shell : /usr/bin/bash -e {0}
3948
4049 - name : Run Gradle Tests
You can’t perform that action at this time.
0 commit comments