-
Notifications
You must be signed in to change notification settings - Fork 0
Task/#104 net 10 upgrade #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,6 @@ jobs: | |
| steps: | ||
| - uses: actions/[email protected] | ||
|
|
||
| - name: Install NET 9 | ||
| uses: actions/[email protected] | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Get the version | ||
| id: get_version | ||
| uses: battila7/get-version-action@v2 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ | |
| types: [published] | ||
|
|
||
| jobs: | ||
| buildlinux: | ||
| build: | ||
| name: "Release" | ||
| env: | ||
| ASPNETCORE_ENVIRONMENT: "Production" | ||
|
|
@@ -15,11 +15,6 @@ | |
| steps: | ||
| - uses: actions/[email protected] | ||
|
|
||
| - name: Install NET 9 | ||
| uses: actions/[email protected] | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Get the version | ||
| id: get_version | ||
| run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
|
|
@@ -46,7 +41,7 @@ | |
|
|
||
| - name: Publish API | ||
| if: ${{ github.event.release.prerelease == false }} | ||
| run: dotnet publish "TestHosts\TestHosts\TestHosts.csproj" --configuration Release --output publishOutput -r linux-x64 --self-contained | ||
| run: dotnet publish "TestHosts\TestHosts\TestHosts.csproj" --configuration Release --output publishOutput -r win-x64 --self-contained | ||
|
|
||
| - name: Build Release Package | ||
| run: | | ||
|
|
@@ -60,159 +55,67 @@ | |
| path: testhosts.zip | ||
|
|
||
| deploystaging: | ||
| runs-on: [stagingserver, linux] | ||
| needs: buildlinux | ||
| runs-on: [stagingserver, windows] | ||
| needs: build | ||
| environment: staging | ||
| name: "Deploy to Staging" | ||
|
|
||
| steps: | ||
| - name: Download the artifact | ||
| uses: actions/[email protected] | ||
| with: | ||
| name: testhosts | ||
| path: /tmp/testhosts # Download to a temporary directory | ||
|
|
||
| - name: Remove existing service (if applicable) | ||
| - name: Remove existing Windows service | ||
| run: | | ||
| SERVICE_NAME="testhosts" | ||
| 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 | ||
| $serviceName = "Transaction Processing - Test Hosts" | ||
| # Check if the service exists | ||
| if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { | ||
| Stop-Service -Name $serviceName | ||
| sc.exe delete $serviceName | ||
| } | ||
|
|
||
| - name: Unzip the files | ||
| run: | | ||
| sudo mkdir -p /opt/txnproc/transactionprocessing/testhosts | ||
| sudo unzip -o /tmp/testhosts/testhosts.zip -d /opt/txnproc/transactionprocessing/testhosts | ||
|
|
||
| # 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: | | ||
| # 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: Install and Start as a Linux service | ||
| Expand-Archive -Path testhosts.zip -DestinationPath "C:\txnproc\transactionprocessing\testhosts" -Force | ||
|
|
||
| - name: Install as a Windows service | ||
| run: | | ||
| SERVICE_NAME="testhosts" | ||
| # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files | ||
| WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/testhosts" | ||
| DLL_NAME="TestHosts.dll" # Your application's DLL | ||
| SERVICE_DESCRIPTION="Transaction Processing - Test Hosts" | ||
|
|
||
| # 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 | ||
| $serviceName = "Transaction Processing - Test Hosts" | ||
| $servicePath = "C:\txnproc\transactionprocessing\testhosts\testhosts.exe" | ||
|
|
||
| New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic | ||
| Start-Service -Name $serviceName | ||
|
|
||
| deployproduction: | ||
Check warningCode 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, linux] | ||
| needs: [buildlinux, deploystaging] | ||
| runs-on: [productionserver, windows] | ||
| needs: [build, deploystaging] | ||
| environment: production | ||
| name: "Deploy to Production" | ||
|
|
||
| steps: | ||
| - name: Download the artifact | ||
| uses: actions/[email protected] | ||
| with: | ||
| name: testhosts | ||
| path: /tmp/testhosts # Download to a temporary directory | ||
|
|
||
| - name: Remove existing service (if applicable) | ||
| - name: Remove existing Windows service | ||
| run: | | ||
| SERVICE_NAME="testhosts" | ||
| 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 | ||
| $serviceName = "Transaction Processing - Test Hosts" | ||
| # Check if the service exists | ||
| if (Get-Service -Name $serviceName -ErrorAction SilentlyContinue) { | ||
| Stop-Service -Name $serviceName | ||
| sc.exe delete $serviceName | ||
| } | ||
|
|
||
| - name: Unzip the files | ||
| run: | | ||
| sudo mkdir -p /opt/txnproc/transactionprocessing/testhosts | ||
| sudo unzip -o /tmp/testhosts/testhosts.zip -d /opt/txnproc/transactionprocessing/testhosts | ||
|
|
||
| # 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: | | ||
| # 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: Install and Start as a Linux service | ||
| Expand-Archive -Path testhosts.zip -DestinationPath "C:\txnproc\transactionprocessing\testhosts" -Force | ||
|
|
||
| - name: Install as a Windows service | ||
| run: | | ||
| SERVICE_NAME="testhosts" | ||
| # The WorkingDirectory is crucial for .NET apps to find appsettings.json and other files | ||
| WORKING_DIRECTORY="/opt/txnproc/transactionprocessing/testhosts" | ||
| DLL_NAME="TestHosts.dll" # Your application's DLL | ||
| SERVICE_DESCRIPTION="Transaction Processing - Test Hosts" | ||
|
|
||
| # 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 | ||
| $serviceName = "Transaction Processing - Test Hosts" | ||
| $servicePath = "C:\txnproc\transactionprocessing\testhosts\testhosts.exe" | ||
|
|
||
| New-Service -Name $serviceName -BinaryPathName $servicePath -Description $serviceName -DisplayName $serviceName -StartupType Automatic | ||
| Start-Service -Name $serviceName | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,11 +15,6 @@ jobs: | |
|
|
||
| steps: | ||
| - uses: actions/[email protected] | ||
|
|
||
| - name: Install NET 9 | ||
| uses: actions/[email protected] | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
|
|
||
| - name: Restore Nuget Packages | ||
| run: dotnet restore TestHosts/TestHosts.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,12 +17,7 @@ jobs: | |
| steps: | ||
| - uses: actions/[email protected] | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install NET 9 | ||
| uses: actions/[email protected] | ||
| with: | ||
| dotnet-version: '9.0.x' | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Restore Nuget Packages | ||
| run: dotnet restore TestHosts/TestHosts.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }} | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 5 months ago
To fix this issue, explicitly add a
permissionsblock at the root of the workflow file. Begin by setting the permissions to the lowest possible value (read-only access forcontents), and elevate permissions only in those jobs or steps that genuinely require them (such as jobs using actions that upload or download artifacts, though most such actions only requirecontents: read). Since the workflow mainly restores/builds code, interacts with docker, and uploads/downloads artifacts,contents: readwill likely suffice. Set this block immediately after thename:declaration and before theon:block to ensure it applies globally to all jobs, unless overridden by a job-levelpermissionsblock.