-
Notifications
You must be signed in to change notification settings - Fork 0
Merge dev-release-ci to Dev #162
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
27 commits
Select commit
Hold shift + click to select a range
f688c51
updated packages
vb2007 4d6fa55
created build & deploy gh workflow file
vb2007 b3e07bd
added job logic for auto deploy
vb2007 d719a33
added task for deploying new commands
vb2007 6b0d2b4
added steps for db updates & config.json syntax verification
vb2007 e6648ba
removed step for config.json syntax verification
vb2007 6a5ffc9
added missing work dirs, added verifiaction for command deployment
vb2007 2e7e6b1
added process exit at the end of table create script
vb2007 c23f307
added output verification for table create script
vb2007 8a9f415
added multiple branch choice for deploy workflow
vb2007 a3f0695
added pr trigger for testing
vb2007 08ed163
updated debug trigger
vb2007 da090e8
changed node install method
vb2007 0d7e4f7
removed unused import from create-tables script
vb2007 c2c10a3
fixed exit code in create-tables
vb2007 92b88ba
fixed node packag lock delete in workflow
vb2007 cc28891
updated variables in workflow
vb2007 3fb99d8
added .env variable checks to command deploy script
vb2007 3c21fd6
fixed extra variable in script
vb2007 e558c90
added extra echos for debugging workflow
vb2007 05cbf84
removed debug logs
vb2007 4f38ed2
added env paths to jobs that use npm
vb2007 9dccfbc
updated echo formatting
vb2007 b609683
temporarly changed default branch
vb2007 676b4a2
fixed test branch
vb2007 84b03b7
removed debug triggers
vb2007 65b322d
supressed codeql permission warnings
vb2007 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 |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| name: Build and Deploy | ||
| permissions: {} | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
| inputs: | ||
| branch: | ||
| description: "Branch to deploy" | ||
| required: true | ||
| default: "main" | ||
| type: string | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: self-hosted # REQUIRES SOME SUDO EXECUTION PRIVILEGES WITHOUT A PASSWORD PROMPT | ||
|
|
||
| steps: | ||
| - name: Stopping systemd service | ||
| run: sudo systemctl stop discordbot | ||
|
|
||
| - name: Pulling latest changes | ||
| working-directory: /home/vb2007/prod/discordbot | ||
| run: | | ||
| BRANCH="${{ github.event.inputs.branch || 'main' }}" | ||
| echo "Deploying branch: $BRANCH" | ||
| git fetch origin | ||
| git reset --hard origin/$BRANCH | ||
| git clean -fd | ||
| echo "✅ Successfully pulled latest changes from $BRANCH" | ||
|
|
||
| # i use manual node paths and manage version manually w/ nvm | ||
| # - name: Setup Node.js | ||
| # uses: actions/setup-node@v4 | ||
| # with: | ||
| # node-version: "24.8.0" | ||
|
|
||
| - name: Intalling Node.js dependencies | ||
| working-directory: /home/vb2007/prod/discordbot | ||
| env: | ||
| PATH: /home/vb2007/.nvm/versions/node/v24.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
| run: | | ||
| rm -rf node_modules | ||
| npm ci | ||
| echo "✅ Dependencies installed successfully" | ||
|
|
||
| # for now we run without building | ||
| # - name: Build the application | ||
| # working-directory: /home/vb2007/prod/discordbot | ||
| # run: | | ||
| # npm run build | ||
| # echo "Application built successfully" | ||
|
|
||
| - name: Deploying possible new commands | ||
| working-directory: /home/vb2007/prod/discordbot | ||
| env: | ||
| PATH: /home/vb2007/.nvm/versions/node/v24.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
| run: | | ||
| echo "Starting command deployment..." | ||
| deployOutput=$(npm run deploy 2>&1) | ||
| echo "$deployOutput" | ||
|
|
||
| if echo "$deployOutput" | grep -q "Registered .* slash (/) commands at Discord"; then | ||
| echo "✅ Command deployment successful" | ||
| else | ||
| echo "❌ Command deployment failed" | ||
| exit 1 | ||
| fi | ||
| sleep 8 | ||
|
|
||
| - name: Updating command data | ||
| working-directory: /home/vb2007/prod/discordbot | ||
| env: | ||
| PATH: /home/vb2007/.nvm/versions/node/v24.8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
| run: | | ||
| echo "Starting table creation and command data update..." | ||
| queriesOutput=$(npm run create-tables 2>&1) | ||
| echo "$queriesOutput" | ||
|
|
||
| if echo "$queriesOutput" | grep -q "All queries are executed & all tables are processed." && echo "$queriesOutput" | grep -q "Command data has been updated successfully."; then | ||
| echo "✅ Table creation and command data update successful" | ||
| else | ||
| echo "❌ Table creation or command data update failed" | ||
| exit 1 | ||
| fi | ||
| sleep 5 | ||
|
|
||
| - name: Starting systemd service | ||
| run: | | ||
| sudo systemctl start discordbot | ||
| sleep 5 | ||
| sudo systemctl status discordbot --no-pager | ||
| echo "Systemd service started" | ||
|
|
||
| - name: Verifying deployment outcome | ||
| run: | | ||
| echo "Waiting for the service to start" | ||
| sleep 10 | ||
|
|
||
| if sudo systemctl is-active --quiet discordbot.service; then | ||
| echo "✅ Deployment successful - service is running" | ||
| else | ||
| echo "❌ Deployment failed - service is not running" | ||
| sudo systemctl status discordbot.service --no-pager | ||
| exit 1 | ||
| fi | ||
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 9 months ago
The best way to address this is to explicitly set the minimal possible
permissionsat the workflow or job level. Since this workflow does not interact with the GitHub API (e.g., does not push, create issues/PRs, etc.), it likely does not require any permissions, so we can setpermissions: {}(no permissions). For maximum clarity and compatibility, and to make explicit the restricted policy, we add at the top-level of the workflow (after thenamekey and beforeon:) apermissions: {}block. If in future the workflow is extended to perform any GitHub API operations, only the minimum required permissions should be added.Edits required:
Insert the
permissions: {}line aftername: Build and Deploy, i.e., between lines 1 and 2.