Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 216 additions & 58 deletions .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,119 +64,277 @@
path: /home/runner/work/SupportTools/SupportTools/TransactionProcessing.SchedulerService/schedulerservice.zip

deploystaging:
runs-on: stagingserver
runs-on: [stagingserver, linux]
needs: buildlinux
environment: staging
name: "Deploy to Staging"

steps:
- name: Download the artifact (Health Check UI)
uses: actions/download-artifact@v4.1.8
with:
name: healthchecksui
path: /tmp/supporttools/healthcheckui

- name: Remove existing Windows service (Health Check UI)
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
# This assumes it's not already there. If your base image already has it, you can skip this.
- name: Install .NET Runtime
run: |
$serviceName = "Transaction Processing - Health Checks UI"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
# and if you need the SDK or just the runtime.
# This uses Microsoft's package repository for the latest versions.
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0

- name: Remove existing service (Health Check UI)
run: |
SERVICE_NAME="healthchecksui"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi

- name: Unzip the files (Health Check UI)
run: |
Expand-Archive -Path healthchecksui.zip -DestinationPath "C:\txnproc\transactionprocessing\supporttools\healthcheckui" -Force
sudo mkdir -p /opt/txnproc/transactionprocessing/supporttools/healthcheckui
sudo unzip -o /tmp/supporttools/healthcheckui/healthcheckui.zip -d /opt/txnproc/transactionprocessing/supporttools/healthcheckui

- name: Install as a Windows service (Health Check UI)
- name: Install and Start as a Linux service (Health Check UI)
run: |
$serviceName = "Transaction Processing - Health Checks UI"
$servicePath = "C:\txnproc\transactionprocessing\supporttools\healthcheckui\TransactionProcessor.HealthChecksUI.exe"

New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Health Checks UI" -DisplayName "Transaction Processing - Health Checks UI" -StartupType Automatic
Start-Service -Name $serviceName
SERVICE_NAME="healthcheckui"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/supporttools/healthcheckui"
DLL_NAME="TransactionProcessor.HealthChecksUI.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Health Checks UI"

# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification

- name: Download the artifact (Scheduler Service)
uses: actions/download-artifact@v4.1.8
with:
name: schedulerservice
path: /tmp/supporttools/schedulerservice

- name: Remove existing Windows service (Scheduler Service)
- name: Remove existing service (Scheduler Service)
run: |
$serviceName = "Transaction Processing - Scheduler Service"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
SERVICE_NAME="schedulerservice"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi

- name: Unzip the files (Scheduler Service)
run: |
Expand-Archive -Path schedulerservice.zip -DestinationPath "C:\txnproc\transactionprocessing\supporttools\schedulerservice" -Force
sudo mkdir -p /opt/txnproc/transactionprocessing/supporttools/schedulerservice
sudo unzip -o /tmp/supporttools/schedulerservice/schedulerservice.zip -d /opt/txnproc/transactionprocessing/supporttools/schedulerservice

- name: Install as a Windows service (Scheduler Service)
- name: Install and Start as a Linux service (Scheduler Service)
run: |
$serviceName = "Transaction Processing - Scheduler Service"
$servicePath = "C:\txnproc\transactionprocessing\supporttools\schedulerservice\TransactionProcessing.SchedulerService.exe"

New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Scheduler Service" -DisplayName "Transaction Processing - Scheduler Service" -StartupType Automatic
Start-Service -Name $serviceName
SERVICE_NAME="schedulerservice"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/supporttools/schedulerservice"
DLL_NAME="TransactionProcessing.SchedulerService.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Scheduler Service"

# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification

deployproduction:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
runs-on: productionserver
runs-on: [productionserver, linux]
needs: [buildlinux, deploystaging]
environment: production
name: "Deploy to Production"

steps:
- name: Download the artifact (Health Check UI)
uses: actions/download-artifact@v4.1.8
with:
name: healthchecksui
path: /tmp/supporttools/healthcheckui

- name: Remove existing Windows service (Health Check UI)
# IMPORTANT: Add a step to ensure the .NET runtime is installed on the server
# This assumes it's not already there. If your base image already has it, you can skip this.
- name: Install .NET Runtime
run: |
$serviceName = "Transaction Processing - Health Checks UI"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
# Example for Ubuntu. Adjust based on your .NET version (e.g., 8.0, 7.0)
# and if you need the SDK or just the runtime.
# This uses Microsoft's package repository for the latest versions.
wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y aspnetcore-runtime-9.0

- name: Remove existing service (Health Check UI)
run: |
SERVICE_NAME="healthchecksui"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi

- name: Unzip the files (Health Check UI)
run: |
Expand-Archive -Path healthchecksui.zip -DestinationPath "C:\txnproc\transactionprocessing\supporttools\healthcheckui" -Force
sudo mkdir -p /opt/txnproc/transactionprocessing/supporttools/healthcheckui
sudo unzip -o /tmp/supporttools/healthcheckui/healthcheckui.zip -d /opt/txnproc/transactionprocessing/supporttools/healthcheckui

- name: Install as a Windows service (Health Check UI)
- name: Install and Start as a Linux service (Health Check UI)
run: |
$serviceName = "Transaction Processing - Health Checks UI"
$servicePath = "C:\txnproc\transactionprocessing\supporttools\healthcheckui\TransactionProcessor.HealthChecksUI.exe"

New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Health Checks UI" -DisplayName "Transaction Processing - Health Checks UI" -StartupType Automatic
Start-Service -Name $serviceName
SERVICE_NAME="healthcheckui"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/supporttools/healthcheckui"
DLL_NAME="TransactionProcessor.HealthChecksUI.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Health Checks UI"

# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification

- name: Download the artifact (Scheduler Service)
uses: actions/download-artifact@v4.1.8
with:
name: schedulerservice
path: /tmp/supporttools/schedulerservice

- name: Remove existing Windows service (Scheduler Service)
- name: Remove existing service (Scheduler Service)
run: |
$serviceName = "Transaction Processing - Scheduler Service"
# Check if the service exists
if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) {
Stop-Service -Name $serviceName
sc.exe delete $serviceName
}
SERVICE_NAME="schedulerservice"
if systemctl is-active --quiet "$SERVICE_NAME"; then
echo "Stopping existing service..."
sudo systemctl stop "$SERVICE_NAME"
fi
if systemctl is-enabled --quiet "$SERVICE_NAME"; then
echo "Disabling existing service..."
sudo systemctl disable "$SERVICE_NAME"
fi
if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]; then
echo "Removing existing service unit file..."
sudo rm "/etc/systemd/system/${SERVICE_NAME}.service"
sudo systemctl daemon-reload
fi

- name: Unzip the files (Scheduler Service)
run: |
Expand-Archive -Path schedulerservice.zip -DestinationPath "C:\txnproc\transactionprocessing\supporttools\schedulerservice" -Force
sudo mkdir -p /opt/txnproc/transactionprocessing/supporttools/schedulerservice
sudo unzip -o /tmp/supporttools/schedulerservice/schedulerservice.zip -d /opt/txnproc/transactionprocessing/supporttools/schedulerservice

- name: Install as a Windows service (Scheduler Service)
- name: Install and Start as a Linux service (Scheduler Service)
run: |
$serviceName = "Transaction Processing - Scheduler Service"
$servicePath = "C:\txnproc\transactionprocessing\supporttools\schedulerservice\TransactionProcessing.SchedulerService.exe"

New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Scheduler Service" -DisplayName "Transaction Processing - Scheduler Service" -StartupType Automatic
Start-Service -Name $serviceName
SERVICE_NAME="schedulerservice"
# The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files
WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/supporttools/schedulerservice"
DLL_NAME="TransactionProcessing.SchedulerService.dll" # Your application's DLL
SERVICE_DESCRIPTION="Transaction Processing - Scheduler Service"

# Create a systemd service file
echo "[Unit]" | sudo tee /etc/systemd/system/${SERVICE_NAME}.service
echo "Description=${SERVICE_DESCRIPTION}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "After=network.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Service]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
# IMPORTANT: Use 'dotnet' to run your DLL
echo "ExecStart=/usr/bin/dotnet ${WORKING_DIRECTORY}/${DLL_NAME}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WorkingDirectory=${WORKING_DIRECTORY}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "User=youruser" # IMPORTANT: Change to a dedicated, less privileged user
echo "Group=yourgroup" # IMPORTANT: Change to a dedicated, less privileged group
echo "Environment=ASPNETCORE_ENVIRONMENT=Production" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service # Example
echo "" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "[Install]" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service

# Reload systemd, enable, and start the service
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
sudo systemctl status "$SERVICE_NAME" --no-pager # For debugging/verification

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}

Copilot Autofix

AI 10 months ago

To fix the issue, add a permissions block to the workflow file to explicitly define the least privileges required for the GITHUB_TOKEN. Since the workflow involves deploying services and uploading artifacts, the contents: read permission is likely sufficient. If specific write permissions are required (e.g., for pull requests or issues), they should be added explicitly.

The permissions block can be added at the root level of the workflow to apply to all jobs or within individual jobs to tailor permissions for each job.


Suggested changeset 1
.github/workflows/createrelease.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/createrelease.yml b/.github/workflows/createrelease.yml
--- a/.github/workflows/createrelease.yml
+++ b/.github/workflows/createrelease.yml
@@ -6,2 +6,5 @@
 
+permissions:
+  contents: read
+
 jobs:
EOF
@@ -6,2 +6,5 @@

permissions:
contents: read

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
Loading