【发布时间】:2020-01-15 04:45:53
【问题描述】:
我正在尝试从 GitHub 操作推送到远程 origin。我的行动逻辑是:
- 处理
pull_request_review事件并按评论消息过滤 - checkout 到 master,合并 PR 分支,运行一些检查并将其推送到
origin
脚本是:
if [[ "${GITHUB_EVENT_NAME}" != "pull_request_review" ]]; then
echo "unsupported event: ${GITHUB_EVENT_NAME}"
exit 1
fi
user=$(jq -r .review.user.login ${GITHUB_EVENT_PATH})
cmd=$(jq -r .review.body ${GITHUB_EVENT_PATH})
echo "reviewer is ${user}, command is ${cmd}"
if [[ "${cmd}" == "merge" ]]; then
head=$(jq -r .pull_request.head.ref ${GITHUB_EVENT_PATH})
git config user.email test@test.com
git config user.name test
git checkout -B _tmp origin/${head}
git checkout -B master origin/master
git merge --no-ff _tmp
git push origin master
fi
我正在从alpine:3.10 Docker 容器运行这个脚本:
FROM alpine:3.10
LABEL "com.github.actions.name"="Hello world action"
LABEL "com.github.actions.icon"="shield"
LABEL "com.github.actions.color"="green"
WORKDIR /app
COPY action.sh action.sh
RUN apk --update add bash git jq
CMD ["bash", "/app/action.sh"]
第一步工作正常(结帐和合并),但由于错误,操作未能将合并推送到origin:
+ git push origin master
致命:无法读取“https://github.com”的用户名:没有这样的设备或地址
看起来 GitHub-action Docker 容器未配置为推送到 GitHub。我该如何配置它?是否可以使用 GitHub 提供的一些 env variables 或一些挂载的文件(如在 /github/* 路径中)?
【问题讨论】:
标签: git docker github github-actions building-github-actions