大佬教程收集整理的这篇文章主要介绍了Github 操作 - 错误:进程已完成,退出代码为 1,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试设置 github 操作来部署我的应用程序。
我用于启动部署过程的 bash
脚本如下所示:
#!/bin/sh
set -e
vendor/bin/phpunit
(git push) || true
git checkout production
git merge master
git push origin production
git checkout master
执行上述脚本时,我得到:
我的 workflows/main.yml
文件如下所示:
name: CD
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.PUSH_TOKEN }}
# - name: Set up Node
# uses: actions/setup-node@v1
# with:
# node-version: '12.x'
# - run: npm install
# - run: npm run production
- name: Commit built assets
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout -B deploy
git add -f public/
git commit -m "Build front-end assets"
git push -f origin deploy
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
username: root
host: xx.xx.xxx.xxx
password: ${{ secrets.SSH_password }}
script: 'cd /var/www/myProject && ./server_deploy.sh'
运行脚本时,我得到以下原始日志:
2021-03-14T16:04:06.7573174Z ##[section]StarTing: request a runner to run this job
2021-03-14T16:04:07.1344029Z Can't find any online and IDle self-hosted runner in current repository that matches the required labels: 'ubuntu-latest'
2021-03-14T16:04:07.1344097Z Can't find any online and IDle self-hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2021-03-14T16:04:07.1344652Z Found online and IDle hosted runner in current repository's account/organization that matches the required labels: 'ubuntu-latest'
2021-03-14T16:04:07.2661405Z ##[section]Finishing: request a runner to run this job
2021-03-14T16:04:17.0975920Z Current runner version: '2.277.1'
2021-03-14T16:04:17.9082004Z ##[group]OperaTing System
2021-03-14T16:04:17.9083391Z Ubuntu
2021-03-14T16:04:17.9084015Z 20.04.2
2021-03-14T16:04:17.9084509Z LTS
2021-03-14T16:04:17.9085154Z ##[endgroup]
2021-03-14T16:04:17.9085790Z ##[group]Virtual Environment
2021-03-14T16:04:17.9086576Z Environment: ubuntu-20.04
2021-03-14T16:04:17.9087226Z Version: 20210302.0
2021-03-14T16:04:17.9088413Z Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20210302.0/images/linux/Ubuntu2004-README.md
2021-03-14T16:04:17.9090008Z Image Release: https://github.com/actions/virtual-environments/releases/tag/ubuntu20%2F
2021-03-14T16:04:17.9091225Z ##[endgroup]
2021-03-14T16:04:17.9093732Z ##[group]GITHUB_TOKEN Permissions
2021-03-14T16:04:17.9095423Z Actions: write
2021-03-14T16:04:17.9096121Z checks: write
2021-03-14T16:04:17.9096752Z Contents: write
2021-03-14T16:04:17.9097367Z Deployments: write
2021-03-14T16:04:17.9098205Z Issues: write
2021-03-14T16:04:17.9098869Z Metadata: read
2021-03-14T16:04:17.9099572Z OrganizationPackages: write
2021-03-14T16:04:17.9100326Z Packages: write
2021-03-14T16:04:17.9100966Z Pullrequests: write
2021-03-14T16:04:17.9101747Z RepositoryProjects: write
2021-03-14T16:04:17.9102476Z SecurityEvents: write
2021-03-14T16:04:17.9103267Z Statuses: write
2021-03-14T16:04:17.9103974Z ##[endgroup]
2021-03-14T16:04:17.9108171Z Prepare workflow directory
2021-03-14T16:04:18.3861957Z Prepare all required actions
2021-03-14T16:04:18.3875377Z GetTing action download info
2021-03-14T16:04:18.7415606Z Download action repository 'actions/checkout@v2'
2021-03-14T16:04:19.4196162Z Download action repository 'appleboy/ssh-action@master'
2021-03-14T16:04:20.1340765Z ##[group]Build container for action use: '/home/runner/work/_actions/appleboy/ssh-action/master/Dockerfile'.
2021-03-14T16:04:20.1449431Z ##[command]/usr/bin/docker build -t 5588e4:46e0c05d2f1c4fbf93b7f69ca6a2f1b5 -f "/home/runner/work/_actions/appleboy/ssh-action/master/Dockerfile" "/home/runner/work/_actions/appleboy/ssh-action/master"
2021-03-14T16:04:21.6962547Z Sending build context to Docker daemon 293.9kB
2021-03-14T16:04:21.6963066Z
2021-03-14T16:04:21.6963632Z Step 1/4 : FROM appleboy/drone-ssh:1.6.3-linux-amd64
2021-03-14T16:04:21.6964381Z 1.6.3-linux-amd64: Pulling from appleboy/drone-ssh
2021-03-14T16:04:21.6965036Z 188c0c94c7c5: Pulling fs layer
2021-03-14T16:04:21.6965576Z 66fca843054b: Pulling fs layer
2021-03-14T16:04:21.6966101Z f62e9573bab1: Pulling fs layer
2021-03-14T16:04:21.6966632Z 06a0f34100cd: Pulling fs layer
2021-03-14T16:04:21.6967110Z 06a0f34100cd: WaiTing
2021-03-14T16:04:21.6967633Z f62e9573bab1: Verifying checksum
2021-03-14T16:04:21.6968295Z f62e9573bab1: Download complete
2021-03-14T16:04:21.6968871Z 66fca843054b: Verifying checksum
2021-03-14T16:04:21.6969544Z 66fca843054b: Download complete
2021-03-14T16:04:21.6970079Z 188c0c94c7c5: Verifying checksum
2021-03-14T16:04:21.6970589Z 188c0c94c7c5: Download complete
2021-03-14T16:04:21.6971347Z 06a0f34100cd: Verifying checksum
2021-03-14T16:04:21.6971878Z 06a0f34100cd: Download complete
2021-03-14T16:04:22.0484952Z 188c0c94c7c5: Pull complete
2021-03-14T16:04:22.2702074Z 66fca843054b: Pull complete
2021-03-14T16:04:22.3773889Z f62e9573bab1: Pull complete
2021-03-14T16:04:22.6271473Z 06a0f34100cd: Pull complete
2021-03-14T16:04:22.6379226Z Digest: sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaa
2021-03-14T16:04:22.6402600Z Status: Downloaded newer image for appleboy/drone-ssh:1.6.3-linux-amd64
2021-03-14T16:04:22.6418359Z ---> 47f94d42e479
2021-03-14T16:04:22.6422631Z Step 2/4 : copY entrypoint.sh /entrypoint.sh
2021-03-14T16:04:23.2992272Z ---> 894dff86e37f
2021-03-14T16:04:23.3137154Z Step 3/4 : RUN chmod +x /entrypoint.sh
2021-03-14T16:04:23.3492501Z ---> Running in 8b348a5718bd
2021-03-14T16:04:25.0149456Z Removing intermediate container 8b348a5718bd
2021-03-14T16:04:25.0167277Z ---> 2bc40f78951d
2021-03-14T16:04:25.0168110Z Step 4/4 : ENTRYPOINT ["/entrypoint.sh"]
2021-03-14T16:04:25.0374209Z ---> Running in be0a69eed1dc
2021-03-14T16:04:26.0155734Z Removing intermediate container be0a69eed1dc
2021-03-14T16:04:26.0157218Z ---> e08d3462082b
2021-03-14T16:04:26.0218123Z successfully built e08d3462082b
2021-03-14T16:04:26.0355661Z successfully tagged 5588e4:46e0c05d2f1c4fbf93b7f69ca6a2f1b5
2021-03-14T16:04:26.0368493Z ##[endgroup]
2021-03-14T16:04:26.0761189Z ##[group]Run actions/checkout@v2
2021-03-14T16:04:26.0761944Z with:
2021-03-14T16:04:26.0763619Z token: ***
2021-03-14T16:04:26.0764261Z repository: myUser/myProject
2021-03-14T16:04:26.0764899Z ssh-Strict: true
2021-03-14T16:04:26.0765450Z persist-credentials: true
2021-03-14T16:04:26.0765987Z clean: true
2021-03-14T16:04:26.0766410Z fetch-depth: 1
2021-03-14T16:04:26.0766837Z lfs: false
2021-03-14T16:04:26.0767254Z submodules: false
2021-03-14T16:04:26.0767708Z ##[endgroup]
2021-03-14T16:04:26.5724570Z Syncing repository: myUser/myProject
2021-03-14T16:04:26.5725598Z ##[group]GetTing Git version info
2021-03-14T16:04:26.5726878Z Working directory is '/home/runner/work/myProject/myProject'
2021-03-14T16:04:26.5728059Z [command]/usr/bin/git version
2021-03-14T16:04:26.5892765Z git version 2.30.1
2021-03-14T16:04:26.5894282Z ##[endgroup]
2021-03-14T16:04:26.5903587Z deleting the contents of '/home/runner/work/myProject/myProject'
2021-03-14T16:04:26.5905407Z ##[group]Initializing the repository
2021-03-14T16:04:26.5909187Z [command]/usr/bin/git init /home/runner/work/myProject/myProject
2021-03-14T16:04:26.6029092Z hint: Using 'master' as the name for the initial branch. This default branch name
2021-03-14T16:04:26.6030401Z hint: is subject to change. To configure the initial branch name to use in all
2021-03-14T16:04:26.6031533Z hint: of your new repositorIEs,which will suppress this warning,call:
2021-03-14T16:04:26.6032386Z hint:
2021-03-14T16:04:26.6033943Z hint: git config --global init.defaultBranch <name>
2021-03-14T16:04:26.6034638Z hint:
2021-03-14T16:04:26.6035442Z hint: names commonly chosen instead of 'master' are 'main','trunk' and
2021-03-14T16:04:26.6036651Z hint: 'development'. The just-created branch can be renamed via this command:
2021-03-14T16:04:26.6037336Z hint:
2021-03-14T16:04:26.6037909Z hint: git branch -m <name>
2021-03-14T16:04:26.6041711Z Initialized empty Git repository in /home/runner/work/myProject/myProject/.git/
2021-03-14T16:04:26.6053565Z [command]/usr/bin/git remote add origin https://github.com/myUser/myProject
2021-03-14T16:04:26.6112480Z ##[endgroup]
2021-03-14T16:04:26.6113335Z ##[group]disabling automatic garbage collection
2021-03-14T16:04:26.6121163Z [command]/usr/bin/git config --local gc.auto 0
2021-03-14T16:04:26.6165369Z ##[endgroup]
2021-03-14T16:04:26.6176967Z ##[group]SetTing up auth
2021-03-14T16:04:26.@R_197_11239@7245Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2021-03-14T16:04:26.6246287Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2021-03-14T16:04:26.6900209Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2021-03-14T16:04:26.6940390Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2021-03-14T16:04:26.7216178Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2021-03-14T16:04:26.7266677Z ##[endgroup]
2021-03-14T16:04:26.7268826Z ##[group]Fetching the repository
2021-03-14T16:04:26.7277912Z [command]/usr/bin/git -c protocol.version=2 fetch --no-Tags --prune --progress --no-recurse-submodules --depth=1 origin +ea9bc17ea94e3e6c966f65eadaab92e81b90346c:refs/remotes/origin/production
2021-03-14T16:04:27.4292763Z remote: EnumeraTing objects: 2050,done.
2021-03-14T16:04:27.5051531Z remote: CounTing objects: 100% (2050/2050),done.
2021-03-14T16:04:27.6195514Z remote: Compressing objects: 100% (1621/1621),done.
2021-03-14T16:04:28.5762484Z Receiving objects: 100% (2050/2050),2.44 MiB | 4.84 MiB/s
2021-03-14T16:04:28.5763176Z Receiving objects: 100% (2050/2050),13.82 MiB | 14.48 MiB/s,done.
2021-03-14T16:04:28.6012285Z Resolving deltas: 100% (469/469)
2021-03-14T16:04:28.6012872Z Resolving deltas: 100% (469/469),done.
2021-03-14T16:04:28.8206899Z From https://github.com/myUser/myProject
2021-03-14T16:04:28.8208438Z * [new ref] ea9bc17ea94e3e6c966f65eadaab92e81b90346c -> origin/production
2021-03-14T16:04:28.8229099Z ##[endgroup]
2021-03-14T16:04:28.8229852Z ##[group]Determining the checkout info
2021-03-14T16:04:28.8232088Z ##[endgroup]
2021-03-14T16:04:28.8232766Z ##[group]checking out the ref
2021-03-14T16:04:28.8236775Z [command]/usr/bin/git checkout --progress --force -B production refs/remotes/origin/production
2021-03-14T16:04:28.9951267Z Switched to a new branch 'production'
2021-03-14T16:04:28.9952452Z Branch 'production' set up to track remote branch 'production' from 'origin'.
2021-03-14T16:04:28.9961000Z ##[endgroup]
2021-03-14T16:04:29.0014527Z [command]/usr/bin/git log -1 --format='%H'
2021-03-14T16:04:29.0046451Z 'ea9bc17ea94e3e6c966f65eadaab92e81b90346c'
2021-03-14T16:04:29.0162817Z ##[group]Run git config --local user.email "action@github.com"
2021-03-14T16:04:29.0163849Z [36;1mgit config --local user.email "action@github.com"[0m
2021-03-14T16:04:29.0164730Z [36;1mgit config --local user.name "GitHub Action"[0m
2021-03-14T16:04:29.0165375Z [36;1mgit checkout -B deploY[0m
2021-03-14T16:04:29.0165987Z [36;1mgit add -f public/[0m
2021-03-14T16:04:29.0166580Z [36;1mgit commit -m "Build front-end assets"[0m
2021-03-14T16:04:29.0167255Z [36;1mgit push -f origin deploY[0m
2021-03-14T16:04:29.0215326Z sHell: /usr/bin/bash -e {0}
2021-03-14T16:04:29.0215807Z ##[endgroup]
2021-03-14T16:04:29.3153383Z Switched to a new branch 'deploy'
2021-03-14T16:04:29.3313550Z On branch deploy
2021-03-14T16:04:29.3316648Z nothing to commit,working tree clean
2021-03-14T16:04:29.3381472Z ##[error]Process completed with exit code 1.
2021-03-14T16:04:29.3653154Z Post job cleanup.
2021-03-14T16:04:29.4723616Z [command]/usr/bin/git version
2021-03-14T16:04:29.4777037Z git version 2.30.1
2021-03-14T16:04:29.4815499Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2021-03-14T16:04:29.4854852Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2021-03-14T16:04:29.5117676Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2021-03-14T16:04:29.5149269Z http.https://github.com/.extraheader
2021-03-14T16:04:29.5160054Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2021-03-14T16:04:29.5197186Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
2021-03-14T16:04:29.5497217Z Cleaning up orphan processes
目前我的生产分支没有提交任何内容,因为生产操作没有开始。
任何建议我做错了什么?
为什么会出现此错误?
非常感谢您的回复!
为什么会出现此错误?
“这个错误”,明确地说,是:
2021-03-14T16:04:29.3381472Z ##[error]Process completed with exit code 1.
完成的过程是sHell:
2021-03-14T16:04:29.0215326Z sHell: /usr/bin/bash -e {0}
在脚本中运行一些命令;显然,那些命令之一必须以状态代码 1(“通用故障”)退出,这导致 bash -e
也以状态代码 1 退出。
我们可以看到每个命令的输出,因此我们可以根据知道哪些命令打印哪些内容,将每个命令与其输出相关联。这是脚本:
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout -B deploy
git add -f public/
git commit -m "Build front-end assets"
git push -f origin deploy
(我取出了变色的 ESC [ ... @H_879_73@m 序列,因为它们只是挡路,并剥离了时间戳,因为它们并不真正相关。)您应该识别这些命令:它们是您在 YAML 文件中提供的命令。
这是每个命令的输出:
Switched to a new branch 'deploy'
On branch deploy
nothing to commit,working tree clean
现在,git config
通常什么都不打印,所以两个 git config
可能成功了,因为我们看到打印了一些东西(第一行)。我们看到打印的是Switched to a new branch 'deploy'
。
这正是 第三个 命令 git checkout -B deploy
在成功时打印的内容。所以我们一定已经达到了第三个命令,它成功了。这将让我们继续第四个命令,git add -f public/
。
git add
命令通常不打印任何内容。所以我们现在不能确定它是否有效,但我们确实看到了进一步的输出,从 On branch ...
开始。这绝对不是来自git add
,所以大概git add
成功了,这让我们继续第五个命令,git commit -m [message]
。此命令确实打印内容,无论成功还是失败:成功时,我们会收到一条消息,显示新提交的缩写哈希 ID,失败时,我们会得到 git status
输出:
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit,working tree clean
$ git commit -m test
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit,working tree clean
这实际上是一种失败:没有什么要提交,所以 Git 不会进行新的提交。为什么没有什么可提交的?因为 Git 的索引匹配当前 (HEAD
) 提交。也就是说,git add -f public/
更新了没有文件。 public/
为空,或者 public/
中的文件与 HEAD
提交中的文件匹配。
如果我们检查以这种方式失败的 git commit
的实际退出状态,它是 1:
$ echo $?
1
所以 git commit
命令是失败的命令,它失败是因为没有新的东西可以提交。
您有多种选择:
弄清楚为什么没有任何东西可以提交,而您显然希望有一些东西可以提交。
检查是否有任何东西要提交,如果没有,什么都不提交。
使用 git commit --allow-empty
指示 Git 进行新的提交,即使不需要新的提交。 (这样做的优点是非常简单。)
通过使用 git commit
构造,强行假设 (cmd || truE)
即使失败也会成功,就像您在此处所做的那样:
(git push) || true
我将这些按不良程度增加的大致顺序排列,尽管其中一些是意见/判断问题。
请注意,在诊断某个脚本的故障时,如果脚本中的哪个命令失败了不是很明显,则有几种方法可以提供帮助。例如,在这里,很明显 git commit
失败了,因为只有 git commit
最终表现得像 git status
,而它正是 当 将失败时这样做带有“无需提交”消息。但是,如果是其他一些更模棱两可的失败呢?可以通过添加 echo
命令来缩小这些失败的范围,以便我们知道脚本的哪些部分正在运行。或者,如果它不会过多地干扰其他事情,我们可以在 bash 脚本中 set -x
:这会导致 sHell 打印输出到标准错误输出,每个命令都有一个 +
行实际上运行,就在运行它之前。这会立即将退出状态固定到生成它的命令。
以上是大佬教程为你收集整理的Github 操作 - 错误:进程已完成,退出代码为 1全部内容,希望文章能够帮你解决Github 操作 - 错误:进程已完成,退出代码为 1所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。