AgentSkillsCN

Deploy to Production

将当前开发分支部署到生产环境。当用户说“/deploy”、“部署到生产”、“推送到Heroku”、“发布到生产”、“部署更改”、“上线”或“发布更改”时使用。提交更改,推送开发分支,合并到主分支,创建版本标签,推送至GitHub和Heroku,然后返回开发分支。

SKILL.md
--- frontmatter
name: Deploy to Production
description: Deploy current develop branch to production. Use when user says /deploy, "deploy to production", "push to heroku", "release to production", "deploy changes", "ship it", or "release changes". Commits changes, pushes develop, merges to main, creates version tag, pushes to GitHub and Heroku, then returns to develop branch.

Deploy to Production Skill

This skill automates the full deployment workflow for Northwest Custom Apparel's Pricing Index project.

What This Skill Does

Executes a complete deployment pipeline:

  1. Commits any uncommitted changes (auto-generated message)
  2. Pushes develop branch to GitHub
  3. Merges develop into main
  4. Creates a version tag (e.g., v2025.12.23.1)
  5. Pushes main to GitHub and Heroku
  6. Returns to develop branch

When to Use This Skill

Use this skill when the user says:

  • "/deploy"
  • "deploy to production"
  • "push to heroku"
  • "release to production"
  • "deploy changes"
  • "ship it"
  • "release changes"

Implementation

Execute these steps in order. Stop immediately if any step fails.

Step 1: Check Current Branch and Status

bash
# Verify we're on develop branch
git branch --show-current

If not on develop, inform the user and stop.

bash
# Check for uncommitted changes
git status --porcelain

Step 2: Commit Changes (if any)

Only run if there are uncommitted changes from Step 1:

bash
# Stage all changes
git add -A

# Get list of changed files for commit message
git diff --cached --name-only

Generate commit message based on changed files:

  • Format: Deploy: updated X files (file1.js, file2.css, ...)
  • If more than 3 files, show first 3 with "... and X more"
bash
# Create commit with auto-generated message
git commit -m "Deploy: updated X files (file1, file2, ...)"

Step 3: Push Develop to GitHub

bash
git push origin develop

Step 4: ASK FOR CONFIRMATION (REQUIRED)

CRITICAL: You MUST ask the user for confirmation before proceeding to production.

Display a summary and ask:

code
READY TO DEPLOY TO PRODUCTION?

Summary so far:
- Branch: develop
- Committed: X files
- Pushed to: GitHub (develop branch)

Next steps will:
- Merge develop → main
- Create version tag
- Push to GitHub (main) and Heroku (PRODUCTION)

Are you ready to proceed?

Use the AskUserQuestion tool to get explicit confirmation. DO NOT proceed without user approval.

If user says no or wants to stop, return to develop branch and stop.

Step 5: Switch to Main Branch

bash
git checkout main

Step 6: Pull Latest Main (Safety Check)

bash
git pull origin main

Step 7: Merge Develop into Main

bash
git merge develop --no-edit

CRITICAL: If merge fails due to conflict:

  1. Run git merge --abort
  2. Run git checkout develop
  3. Display error message to user:
    code
    DEPLOY ABORTED: Merge conflict detected!
    
    Please resolve conflicts manually:
    1. git checkout main
    2. git merge develop
    3. Resolve conflicts in your editor
    4. git add . && git commit
    5. Run /deploy again
    
    You are back on develop branch.
    
  4. STOP - do not continue with remaining steps

Step 8: Create Version Tag

Generate tag in format: vYYYY.MM.DD.N where N is sequence number for the day.

bash
# Get today's date
date +%Y.%m.%d

# Check for existing tags today to determine sequence number
git tag -l "v$(date +%Y.%m.%d).*"

If no tags exist for today, use .1. Otherwise increment the last sequence number.

bash
# Create annotated tag
git tag -a v2025.12.23.1 -m "Production deploy"

Step 9: Push Main to GitHub (with tags)

bash
git push origin main --tags

Step 10: Push Main to Heroku

bash
git push heroku main

Step 11: Return to Develop Branch

bash
git checkout develop

Step 12: Display Success Message

code
DEPLOY SUCCESSFUL!

Summary:
- Committed: X files
- Version tag: v2025.12.23.1
- Pushed to: GitHub (develop + main) and Heroku

Main branch is now live at:
https://sanmar-inventory-app-4cd7b252508d.herokuapp.com/

Step 13: Ask About Lessons Learned (REQUIRED)

After successful deploy, ask:

code
Any bugs fixed this session to log to LESSONS_LEARNED.md?

Use AskUserQuestion with options:

  • "Yes, log a bug fix" → Ask for details, then add entry to /memory/LESSONS_LEARNED.md
  • "No, nothing to log" → Done

If user wants to log, collect:

  • Problem description
  • Symptoms
  • Root cause
  • Solution
  • Prevention (optional)

Then add the entry at the top of LESSONS_LEARNED.md (below the header, above existing entries).

Error Handling

ErrorAction
Not on develop branchStop, inform user
Merge conflictAbort merge, return to develop, show manual resolution steps
Push failsShow error, suggest git pull first
Heroku push failsShow error, suggest checking Heroku login status

Example Output

code
Starting deployment...

[1/12] Checking branch... develop
[2/12] Committing changes... 3 files staged
       Commit: "Deploy: updated 3 files (calculator.js, styles.css, index.html)"
[3/12] Pushing develop to GitHub... done

[4/12] CONFIRMATION REQUIRED...

       READY TO DEPLOY TO PRODUCTION?

       Summary so far:
       - Branch: develop
       - Committed: 3 files
       - Pushed to: GitHub (develop branch)

       Next steps will:
       - Merge develop → main
       - Create version tag
       - Push to GitHub (main) and Heroku (PRODUCTION)

       [User confirms: Yes, proceed]

[5/12] Switching to main... done
[6/12] Pulling latest main... already up to date
[7/12] Merging develop into main... done
[8/12] Creating version tag... v2025.12.23.1
[9/12] Pushing main to GitHub... done
[10/12] Pushing to Heroku... done
[11/12] Returning to develop... done

DEPLOY SUCCESSFUL! Version v2025.12.23.1 is now live.

Important Notes

  • Always verify you're on develop branch before starting
  • Never force push - if push fails, investigate why
  • Version tags provide rollback points: git checkout v2025.12.23.1
  • If Heroku fails but GitHub succeeds, you can manually run git push heroku main