diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..8d96717 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,58 @@ +name: Spring Boot CI/CD + +on: + push: + branches: [ "dev", "feature/*", "fix/*", "test/*" ] + pull_request: + branches: [ "main" ] + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:latest + env: + POSTGRES_DB: smsdb_test + POSTGRES_PASSWORD: pass123 + POSTGRES_USER: admin + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - uses: actions/checkout@v4 + + - name: Setup Java 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + cache: maven + + - name: Test & Build + run: ./mvnw clean verify + env: + SPRING_DATASOURCE_URL: jdbc:postgresql://localhost:5432/smsdb_test + SPRING_DATASOURCE_USERNAME: admin + SPRING_DATASOURCE_PASSWORD: pass123 + SPRING_JPA_HIBERNATE_DDL_AUTO: create-drop + + deploy: + needs: test + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Trigger Render Deployment + run: | + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.RENDER_API_KEY }}" \ + -H "Content-Type: application/json" \ + -d '{}' \ + https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys \ No newline at end of file diff --git a/.gitignore b/.gitignore index 667aaef..618189e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,11 @@ target/ !**/src/main/**/target/ !**/src/test/**/target/ +# Environment files +.env +.env.local +.env.* + ### STS ### .apt_generated .classpath @@ -30,4 +35,4 @@ build/ !**/src/test/**/build/ ### VS Code ### -.vscode/ +.vscode/ \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 00f31bb..f463bca 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,22 +1,40 @@ -# Database Configuration -spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/smsdb} -spring.datasource.username=${SPRING_DATASOURCE_USERNAME:admin} -spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:pass123} +## Database Configuration +#spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/smsdb} +#spring.datasource.username=${SPRING_DATASOURCE_USERNAME:admin} +#spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:pass123} +#spring.datasource.driver-class-name=org.postgresql.Driver +# +## JPA/Hibernate +#spring.jpa.hibernate.ddl-auto=${SPRING_JPA_HIBERNATE_DDL_AUTO:update} +#spring.jpa.show-sql=${SPRING_JPA_SHOW_SQL:false} +#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +#spring.jpa.properties.hibernate.format_sql=true +# +## Server +#server.port=8080 +# +## Thymeleaf +#spring.thymeleaf.prefix=classpath:/templates/ +#spring.thymeleaf.suffix=.html +#spring.thymeleaf.cache=false +# +## Security (for development) +#spring.security.filter.order=10 + +# Database Configuration - Render provides these env vars +spring.datasource.url=${SPRING_DATASOURCE_URL} +spring.datasource.username=${SPRING_DATASOURCE_USERNAME} +spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver # JPA/Hibernate spring.jpa.hibernate.ddl-auto=${SPRING_JPA_HIBERNATE_DDL_AUTO:update} spring.jpa.show-sql=${SPRING_JPA_SHOW_SQL:false} -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.format_sql=true -# Server -server.port=8080 +# Server - Render sets PORT env var +server.port=${PORT:8080} # Thymeleaf -spring.thymeleaf.prefix=classpath:/templates/ -spring.thymeleaf.suffix=.html spring.thymeleaf.cache=false -# Security (for development) -spring.security.filter.order=10 \ No newline at end of file