Skip to content

fix: SSH key corruption in deploy and wrong ldflags package path - #1

Merged
mojocn merged 5 commits into
mainfrom
copilot/fix-github-actions-job-build
Jul 16, 2026
Merged

mojocn merged 5 commits into
mainfrom
copilot/fix-github-actions-job-build

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The CI "build" job was failing at deploy with Permission denied (publickey,password) — SSH key auth silently failed due to potential \r corruption in the key file, then fell back to password auth which also fails. A secondary bug caused gitHash/buildTime to never be injected into the binary.

Changes

.github/workflows/deploy.sh — SSH key handling

  • Strip \r from the key before writing to disk (tr -d '\r') to handle Windows-style line endings in the GitHub Secret
  • Add -o BatchMode=yes -o PasswordAuthentication=no to scp/ssh to disable interactive password fallback and fail fast on key auth failure
- echo "$SSH_KEY" > key.pem
+ echo "$SSH_KEY" | tr -d '\r' > key.pem

- scp -o StrictHostKeyChecking=no -i key.pem ...
+ scp -o StrictHostKeyChecking=no -o BatchMode=yes -o PasswordAuthentication=no -i key.pem ...

.github/workflows/deploy.ymlgo build ldflags

  • gitHash and buildTime are package-level vars in main (config_util.go), not in the non-existent internal/global package. Go silently ignores unknown -X targets, so the binary was always built with empty version info.
- go build -ldflags="-X 'github.com/unchainese/unchain/internal/global.gitHash=...' ..."
+ go build -ldflags="-X 'main.gitHash=...' -X 'main.buildTime=...'"

Copilot AI changed the title [WIP] Fix failing GitHub Actions job build fix: SSH key corruption in deploy and wrong ldflags package path Jul 16, 2026
Copilot AI requested a review from mojocn July 16, 2026 08:18
@mojocn

mojocn commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Merge conflicts resolved in commit fix: resolve merge conflicts with main. The resolution combines our tr -d '\r' fix with the structural improvements from main's deploy.sh (set -e, key validation, UserKnownHostsFile, ConnectTimeout, key cleanup). For deploy.yml, the clean build line from our branch was kept, discarding the duplicate-text artifact in main's version.

@mojocn
mojocn marked this pull request as ready for review July 16, 2026 08:28
Copilot AI review requested due to automatic review settings July 16, 2026 08:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a CI deploy failure caused by SSH key formatting issues (CRLF/\r in the secret) and corrects Go build metadata injection so gitHash/buildTime are properly embedded into the produced binary.

Changes:

  • Harden SSH key materialization in the deploy script by stripping \r before writing key.pem.
  • Make scp/ssh fail fast on auth failures by disabling interactive/password fallback via SSH options.
  • Fix the go build -ldflags -X targets so version variables in the main package are actually set, and clean up a deploy step label typo.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/deploy.yml Fixes Go linker -X targets for version metadata injection and corrects the deploy step label.
.github/workflows/deploy.sh Improves SSH key file creation (CR stripping) and tightens SSH/SCP auth behavior to fail fast.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/deploy.yml
Comment thread .github/workflows/deploy.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mojocn
mojocn merged commit 5db74f4 into main Jul 16, 2026
1 check failed
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.

3 participants