Skip to content
68 changes: 68 additions & 0 deletions .github/workflows/master_vnvssweb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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 PHP app to Azure Web App - vnvssweb

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read #This is required for actions/checkout

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v1
with:
files: 'composer.json'

- name: Run composer install if composer.json exists
if: steps.check_files.outputs.files_exists == 'true'
run: composer validate --no-check-publish && composer install --prefer-dist --no-progress

- name: Zip artifact for deployment
run: zip release.zip ./* -r

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: php-app
path: release.zip

deploy:
runs-on: ubuntu-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@v4
with:
name: php-app

- name: Unzip artifact for deployment
run: unzip release.zip

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'vnvssweb'
slot-name: 'Production'
package: .
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_FED3B8CA42AF4DE7A992EBB2779DB791 }}
16 changes: 14 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
<?php
<?php include "templates/header.php"; ?>

echo "Hello World!";
<div class="center-align">
<ul>
<div class="left-align">
<li><a href="read.php"><strong>View Catalog</strong></a></li>
<li><a href="insert.php"><strong>Add a Product</strong></a></li>
<li><a href="update.php"><strong>Update a Product</strong></a></li>
<li><a href="delete.php"><strong>Remove a Product</strong></a></li>
</div>
</ul>
</div>


<?php include "templates/footer.php"; ?>
52 changes: 52 additions & 0 deletions read.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php require "templates/header.php"; ?>

<div class="center-align">

<?php

require "database/config.php";


//Establish the connection
$conn = mysqli_init();
mysqli_ssl_set($conn,NULL,NULL,$sslcert,NULL,NULL);
if(!mysqli_real_connect($conn, $host, $username, $password, $db_name, 3306, MYSQLI_CLIENT_SSL)){
die('Failed to connect to MySQL: '.mysqli_connect_error());
}

//Test if table exists
$res = mysqli_query($conn, 'SELECT * FROM software_list');

if (mysqli_num_rows($res) <= 0) {
echo "<h2>Catalog is empty.</h2>";
}
else {
echo "<table> <tr align=\"left\"> <th> Product Name </th> <th> Price (USD) </th> </tr>";
while ($row = mysqli_fetch_assoc($res)) {
echo "<tr align=\"left\"> <td> ".$row["ProductName"]." </td>";
echo "<td> ".$row["Price"]." </td> </tr>";
}
echo "</table>";
}
}

//Close the connection
mysqli_close($conn);

?>

<br> <br> <br>

<table>
<tr>
<td> <a href="insert.php">Add a Product</a> </td>
<td> <a href="update.php">Update a Product</a> </td>
<td> <a href="delete.php">Remove a Product</a> </td>
<td> <a href="index.php">Back to Home Page</a> </td>
</tr>
</table>

</div>

<?php require "templates/footer.php"; ?>

3 changes: 3 additions & 0 deletions templates/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
</body>

</html>
15 changes: 15 additions & 0 deletions templates/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Software List</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="center-align">
<h1>Software List</h1>
<br>
</div>