-
Notifications
You must be signed in to change notification settings - Fork 0
Update deployment workflow for Linux support #701
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
3 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 |
|---|---|---|
|
|
@@ -73,67 +73,123 @@ | |
| dotnet nuget push Nugets/SecurityService.IntegrationTesting.Helpers.${{ steps.get_version.outputs.VERSION }}.nupkg --api-key ${{ secrets.PRIVATEFEED_APIKEY }} --source ${{ secrets.PRIVATEFEED_URL }} --skip-duplicate | ||
|
|
||
| deploystaging: | ||
| runs-on: stagingserver | ||
| needs: buildlinux | ||
| environment: staging | ||
| name: "Deploy to Staging" | ||
|
|
||
| steps: | ||
| - name: Download the artifact | ||
| uses: actions/[email protected] | ||
| with: | ||
| name: securityservice | ||
|
|
||
| - name: Remove existing Windows service | ||
| run: | | ||
| $serviceName = "Transaction Processing - Security Service" | ||
| # 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: | | ||
| Expand-Archive -Path securityservice.zip -DestinationPath "C:\txnproc\transactionprocessing\securityservice" -Force | ||
|
|
||
| - name: Install as a Windows service | ||
| run: | | ||
| $serviceName = "Transaction Processing - Security Service" | ||
| $servicePath = "C:\txnproc\transactionprocessing\securityservice\SecurityService.exe" | ||
|
|
||
| New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Security Service" -DisplayName "Transaction Processing - Security Service" -StartupType Automatic | ||
| Start-Service -Name $serviceName | ||
| runs-on: [stagingserver, linux] | ||
| needs: buildlinux | ||
| environment: staging | ||
| name: "Deploy to Staging" | ||
|
|
||
| steps: | ||
| - name: Download the artifact | ||
| uses: actions/[email protected] | ||
| with: | ||
| name: securityservice | ||
| path: /tmp/securityservice # Download to a temporary directory | ||
|
|
||
| - name: Remove existing service (if applicable) | ||
| run: | | ||
| SERVICE_NAME="securityservice" # Or whatever your service will be called | ||
| 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 | ||
| run: | | ||
| mkdir -p /opt/txnproc/transactionprocessing/securityservice | ||
| unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice | ||
|
|
||
| - name: Install and Start as a Linux service | ||
| run: | | ||
| SERVICE_NAME="securityservice" | ||
| EXEC_PATH="/opt/txnproc/transactionprocessing/securityservice/SecurityService" # Assuming your executable is named SecurityService | ||
| SERVICE_DESCRIPTION="Transaction Processing - Security 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 | ||
| echo "ExecStart=${EXEC_PATH}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service | ||
| echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service | ||
| echo "User=youruser" # Consider running as a less privileged user | ||
| echo "Group=yourgroup" # Consider running as a less privileged group | ||
| 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 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 | ||
| runs-on: [productionserver, linux] | ||
| needs: [buildlinux, deploystaging] | ||
| environment: production | ||
| name: "Deploy to Production" | ||
|
|
||
| steps: | ||
| - name: Download the artifact | ||
| uses: actions/[email protected] | ||
| with: | ||
| name: securityservice | ||
|
|
||
| - name: Remove existing Windows service | ||
| run: | | ||
| $serviceName = "Transaction Processing - Security Service" | ||
| # 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: | | ||
| Expand-Archive -Path securityservice.zip -DestinationPath "C:\txnproc\transactionprocessing\securityservice" -Force | ||
|
|
||
| - name: Install as a Windows service | ||
| run: | | ||
| $serviceName = "Transaction Processing - Security Service" | ||
| $servicePath = "C:\txnproc\transactionprocessing\securityservice\SecurityService.exe" | ||
|
|
||
| New-Service -Name $serviceName -BinaryPathName $servicePath -Description "Transaction Processing - Security Service" -DisplayName "Transaction Processing - Security Service" -StartupType Automatic | ||
| Start-Service -Name $serviceName | ||
| - name: Download the artifact | ||
| uses: actions/[email protected] | ||
| with: | ||
| name: securityservice | ||
| path: /tmp/securityservice # Download to a temporary directory | ||
|
|
||
| - name: Remove existing service (if applicable) | ||
| run: | | ||
| SERVICE_NAME="securityservice" # Or whatever your service will be called | ||
| 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 | ||
| run: | | ||
| mkdir -p /opt/txnproc/transactionprocessing/securityservice | ||
| unzip -o /tmp/securityservice/securityservice.zip -d /opt/txnproc/transactionprocessing/securityservice | ||
|
|
||
| - name: Install and Start as a Linux service | ||
| run: | | ||
| SERVICE_NAME="securityservice" | ||
| EXEC_PATH="/opt/txnproc/transactionprocessing/securityservice/SecurityService" # Assuming your executable is named SecurityService | ||
| SERVICE_DESCRIPTION="Transaction Processing - Security 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 | ||
| echo "ExecStart=${EXEC_PATH}" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service | ||
| echo "Restart=always" | sudo tee -a /etc/systemd/system/${SERVICE_NAME}.service | ||
| echo "User=youruser" # Consider running as a less privileged user | ||
| echo "Group=yourgroup" # Consider running as a less privileged group | ||
| 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 | ||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 10 months ago
To fix the issue, we need to add a
permissionsblock to the workflow file. This block should specify the least privileges required for the workflow to function correctly. Since the workflow involves deploying artifacts and pushing NuGet packages, we can setcontents: readfor accessing repository contents andpackages: writefor pushing packages. Other permissions can be omitted unless explicitly required.The
permissionsblock can be added at the root level of the workflow to apply to all jobs or within individual jobs to tailor permissions for specific tasks.