diff --git a/.github/workflows/main_cookingwithethan.yml b/.github/workflows/main_cookingwithethan.yml new file mode 100644 index 000000000..2401ef9e1 --- /dev/null +++ b/.github/workflows/main_cookingwithethan.yml @@ -0,0 +1,53 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy JAR app to Azure Web App - CookingWithEthan + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Java version + uses: actions/setup-java@v1 + with: + java-version: '17' + + - name: Build with Maven + run: mvn clean install + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: java-app + path: '${{ github.workspace }}/target/*.jar' + + deploy: + runs-on: windows-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: java-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'CookingWithEthan' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_10EAA71046584F8C8CF3D793303AE1CC }} + package: '*.jar' diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java index f594b5bc3..1a06c1607 100644 --- a/src/main/java/com/example/demo/DemoApplication.java +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -4,6 +4,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; @SpringBootApplication @RestController @@ -15,6 +18,28 @@ public static void main(String[] args) { @RequestMapping("/") String sayHello() { - return "Hello World!"; + return "Hello Again!"; } } + +public class DatabaseConnection { + public static void main(String[] args) { + // Database connection details + String url = "jdbc:postgresql://familyrecipes.postgres.database.azure.com:5432/{your_database}?user=fryees&password={your_password}&sslmode=require"; + String username = "fryees@familyrecipes"; + String password = "BENTLEYbear555!"; + + + try { + Connection connection = DriverManager.getConnection(url, username, password); + System.out.println("Connected to the PostgreSQL database successfully!"); + // Use the connection to query the database or perform other operations + // ... + connection.close(); + } catch (SQLException e) { + System.out.println("Failed to connect to the PostgreSQL database: " + e.getMessage()); + } + } +} + + diff --git a/src/main/java/com/example/demo/postgresql-42.6.0.jar b/src/main/java/com/example/demo/postgresql-42.6.0.jar new file mode 100644 index 000000000..02f902afc Binary files /dev/null and b/src/main/java/com/example/demo/postgresql-42.6.0.jar differ