admin管理员组文章数量:1401215
I have the following issue, I am trying to set up a GitHub action for continuous deployment, however, I run into issues which I think is caused by the chaining of commands for the SSH.
I'm looking for a cleaner solution and a fix to this.
Here's my hetzner.yml
file:
name: Deploy to Hetzner
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY}}
- name: (Finally) Deploy to Hetzner
run: |
ssh -v ${{ secrets.SSH_OPTS }} ${{ secrets.HETZNER_USER }}
cd myproject
git pull
npm ci
npm run build
npm run start
caddy run
Where, secrets.SSH_OPTS is: (note doublequotes inside)
"-o ServerAliveInterval=600 StrictHostKeyChecking=no"
And secrets.HETZNER_USER is:
[email protected]
The error that I get is:
Run ssh -v *** *** cd myproject git pull npm ci npm run build npm run start caddy run
ssh -v *** *** cd myproject git pull npm ci npm run build npm run start caddy run
shell: /usr/bin/bash -e {0}
env:
SSH_AUTH_SOCK: /tmp/ssh-GLbX9AdHVKNp/agent.1757
SSH_AGENT_PID: 1758
command-line line 0: keyword serveraliveinterval extra arguments at end of line
Error: Process completed with exit code 255.
Any help is much appreciated.
I tried putting the bash commands in single quotes, that works but isn't clean at all.
I have the following issue, I am trying to set up a GitHub action for continuous deployment, however, I run into issues which I think is caused by the chaining of commands for the SSH.
I'm looking for a cleaner solution and a fix to this.
Here's my hetzner.yml
file:
name: Deploy to Hetzner
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY}}
- name: (Finally) Deploy to Hetzner
run: |
ssh -v ${{ secrets.SSH_OPTS }} ${{ secrets.HETZNER_USER }}
cd myproject
git pull
npm ci
npm run build
npm run start
caddy run
Where, secrets.SSH_OPTS is: (note doublequotes inside)
"-o ServerAliveInterval=600 StrictHostKeyChecking=no"
And secrets.HETZNER_USER is:
[email protected]
The error that I get is:
Run ssh -v *** *** cd myproject git pull npm ci npm run build npm run start caddy run
ssh -v *** *** cd myproject git pull npm ci npm run build npm run start caddy run
shell: /usr/bin/bash -e {0}
env:
SSH_AUTH_SOCK: /tmp/ssh-GLbX9AdHVKNp/agent.1757
SSH_AGENT_PID: 1758
command-line line 0: keyword serveraliveinterval extra arguments at end of line
Error: Process completed with exit code 255.
Any help is much appreciated.
I tried putting the bash commands in single quotes, that works but isn't clean at all.
Share Improve this question edited Mar 24 at 12:55 The Dude asked Mar 24 at 12:48 The DudeThe Dude 12 bronze badges 5 |1 Answer
Reset to default 0- name: (Finally) Deploy to Hetzner
run: |
ssh -v ${{ secrets.SSH_OPTS }} ${{ secrets.HETZNER_USER }} "\
cd myproject \
git pull \
npm ci \
npm run build \
npm run start \
caddy run"
Might work.
本文标签: cicdGitHub action chaining multiple commands to SSHStack Overflow
版权声明:本文标题:cicd - GitHub action chaining multiple commands to SSH - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744251003a2597249.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
ssh -o ServerAliveInterval=600 -o StrictHostKeyChecking=no [email protected] 'sh myproject/scripts/deploy.sh
but still caddy run & makes it hang and it never completes. – The Dude Commented Mar 24 at 14:32