Skip to content

Automate VPS deploy via deploy.sh#7

Merged
heidi-dang merged 1 commit intomainfrom
deploy-automation
Jan 27, 2026
Merged

Automate VPS deploy via deploy.sh#7
heidi-dang merged 1 commit intomainfrom
deploy-automation

Conversation

@heidi-dang
Copy link
Owner

  • add a root-safe, non-interactive deploy.sh\n- wire deploy workflow to run deploy.sh via SSH\n- preserve .env during deploy

@gemini-code-assist
Copy link

Summary of Changes

Hello @heidi-dang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a robust, single-script solution for deploying the AutoCoder application to a Virtual Private Server. It streamlines the entire deployment process by automating the setup of Docker, configuring dynamic DNS with DuckDNS, integrating Traefik for reverse proxying and SSL termination via Let's Encrypt, and managing the application's Docker Compose stack. The script is designed to be flexible, supporting both interactive execution for manual deployments and non-interactive, environment-variable-driven execution for CI/CD pipelines, while also ensuring critical configuration files like .env are safely preserved.

Highlights

  • Automated VPS Deployment Script: A new deploy.sh script has been added to provide a one-click solution for deploying the AutoCoder application to a Virtual Private Server. This script automates the entire setup process, from installing Docker to configuring DuckDNS, Traefik, and Let's Encrypt.
  • Environment Variable Preservation: The deployment script includes robust logic to preserve existing .env files during updates, backing them up and restoring them to ensure critical application configurations are not lost. It also warns if .env is tracked by Git.
  • CI/CD Integration Support: The deploy.sh script is designed with automation in mind, supporting non-interactive execution via environment variables (AUTOCODER_AUTOMATED, AUTOCODER_ASSUME_YES, etc.) making it suitable for integration into CI/CD pipelines.
  • Comprehensive Setup and Cleanup: The script handles Docker installation, Git repository cloning/pulling, Docker Compose orchestration, and optional safe cleanup of Docker artifacts, apt caches, and system logs post-deployment.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/deploy.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces deploy.sh, a script designed to automate VPS setup, handling dependencies, configuration, and application deployment. However, a critical command injection vulnerability via cron job manipulation and insecure data handling (sensitive credentials stored in a world-readable file) have been identified. Additionally, the script suppresses potential failures in critical network requests, which could lead to hard-to-diagnose deployment issues. Addressing these security and reliability concerns is crucial.

Comment on lines +169 to +171
cat > "${cron_file}" <<EOF
*/5 * * * * root curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN}&token=${DUCKDNS_TOKEN}&ip=" >/var/log/duckdns.log 2>&1
EOF

Choose a reason for hiding this comment

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

security-critical critical

The script writes user-supplied input (DUCKDNS_SUBDOMAIN and DUCKDNS_TOKEN) directly into a cron file in /etc/cron.d/. If these variables contain newlines, an attacker can inject arbitrary cron jobs that will be executed as root. This is a critical command injection vulnerability, especially if the script is used in automated environments where inputs might be controlled by untrusted parties.

Suggested change
cat > "${cron_file}" <<EOF
*/5 * * * * root curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN}&token=${DUCKDNS_TOKEN}&ip=" >/var/log/duckdns.log 2>&1
EOF
cat > "${cron_file}" <<EOF
*/5 * * * * root curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN//[^a-zA-Z0-9.-]/}&token=${DUCKDNS_TOKEN//[^a-zA-Z0-9-]/}&ip=" >/var/log/duckdns.log 2>&1
EOF

cat > "${cron_file}" <<EOF
*/5 * * * * root curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN}&token=${DUCKDNS_TOKEN}&ip=" >/var/log/duckdns.log 2>&1
EOF
chmod 644 "${cron_file}"

Choose a reason for hiding this comment

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

security-high high

The DUCKDNS_TOKEN is stored in /etc/cron.d/duckdns with world-readable permissions (644), posing a security risk as any user can access this sensitive credential. Permissions should be restricted to 600 to ensure only the root user can access it.

Suggested change
chmod 644 "${cron_file}"
chmod 600 "${cron_file}"

Comment on lines +175 to +176
curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN}&token=${DUCKDNS_TOKEN}&ip=" \
>/var/log/duckdns.log 2>&1 || true

Choose a reason for hiding this comment

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

high

The script currently suppresses errors from the initial DuckDNS update using || true. If this critical step fails (e.g., due to an invalid token), the script continues, which will likely cause the SSL certificate issuance to fail later in a non-obvious way. It's better to check the API response from DuckDNS and provide a clear warning or exit on failure, especially in automated runs.

Suggested change
curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN}&token=${DUCKDNS_TOKEN}&ip=" \
>/var/log/duckdns.log 2>&1 || true
local response
response=$(curl -fsS "https://www.duckdns.org/update?domains=${DUCKDNS_SUBDOMAIN}&token=${DUCKDNS_TOKEN}&ip=" || echo "curl_error")
echo "${response}" >/var/log/duckdns.log 2>&1
if [[ "${response}" != "OK" ]]; then
echo "WARNING: Initial DuckDNS update failed. Response: '${response}'. SSL certificate issuance may fail." >&2
if [[ "${AUTOMATED_MODE}" -eq 1 ]]; then
echo "ERROR: Aborting due to DuckDNS update failure in automated mode." >&2
exit 1
fi
fi

@heidi-dang heidi-dang merged commit 5e1dd83 into main Jan 27, 2026
3 checks passed
@heidi-dang heidi-dang deleted the deploy-automation branch January 27, 2026 11:00
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