Skip to content
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

feat(ci): homelab deploy #322

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat(ci): homelab deploy #322

wants to merge 1 commit into from

Conversation

duyet
Copy link
Owner

@duyet duyet commented Jul 25, 2024

Summary by Sourcery

This pull request introduces a new GitHub Actions workflow for deploying to a homelab environment. The workflow includes steps for setting up Tailscale, adding an SSH key, and executing remote commands to build the project and restart a service.

  • CI:
    • Added a new GitHub Actions workflow for deploying to a homelab environment. The workflow triggers on pushes to the main branch, releases, pull requests, and manual dispatches. It includes steps for setting up Tailscale, adding an SSH key, and executing remote commands to build the project and restart a service.

Copy link

vercel bot commented Jul 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clickhouse-monitoring ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2024 7:28am

Copy link
Contributor

sourcery-ai bot commented Jul 25, 2024

Reviewer's Guide by Sourcery

This pull request introduces a new GitHub Actions workflow for deploying to a homelab environment. The workflow is triggered on various events including pushes to the main branch, releases, pull requests, and manual dispatches. It uses Tailscale for secure network access and SSH for executing build and service restart commands on the remote machine.

File-Level Changes

Files Changes
.github/workflows/homelab.yml Introduced a new CI workflow for deploying to a homelab environment using GitHub Actions, Tailscale for secure access, and SSH for remote command execution.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @duyet - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟡 Security: 2 issues found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.


permissions:
contents: read
id-token: write
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider limiting the scope of the id-token permission.

The 'id-token: write' permission is quite powerful and should be used with caution. If possible, consider limiting its scope to only the necessary actions to minimize security risks.

Suggested change
id-token: write
permissions:
contents: read
id-token: write:actions

Comment on lines 35 to 36
MACHINE_IP="$(tailscale ip -6 $MACHINE)"
ssh-keyscan $MACHINE_IP >> ~/.ssh/known_hosts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Check for potential issues with IPv6-only addresses.

The use of 'tailscale ip -6' assumes that the machine has an IPv6 address. If the machine does not have an IPv6 address, this could cause issues. Consider adding a fallback to IPv4 or handling the case where an IPv6 address is not available.


- run: |
MACHINE_IP="$(tailscale ip -6 $MACHINE)"
ssh -i ~/.ssh/key "github@$MACHINE_IP" "NODE_VERSION=v22.5.1 /home/duyet/.nvm/nvm-exec yarn build"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider using a more secure method for SSH key management.

Storing the SSH key in a file and using it directly can be risky. Consider using an SSH agent or another secure method to manage the SSH key.

Suggested change
ssh -i ~/.ssh/key "github@$MACHINE_IP" "NODE_VERSION=v22.5.1 /home/duyet/.nvm/nvm-exec yarn build"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/key
ssh "github@$MACHINE_IP" "NODE_VERSION=v22.5.1 /home/duyet/.nvm/nvm-exec yarn build"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant