如何从github操作触发推送到远程服务器的推动?
本地设置了这个遥控器
$ git remote -v
dev [email protected]:/home/myuser/maps.git (fetch)
dev [email protected]:/home/myuser/maps.git (push)
我从远程存储库中的
# The production directory
TARGET="/var/www/html"
# A temporary directory for deployment
TEMP="/home/myuser/deploy-folder"
# The Git repo
REPO="/home/myuser/maps.git"
# Deploy the content to the temporary directory
mkdir -p $TEMP
#git --work-tree=$TEMP --git-dir=$REPO checkout -f
cd $TEMP
git pull
...
,我有一个挂钩,〜/maps.git/hooks/tost-receive,我想做的就是每当PR合并到特定分支(身份验证)时,我想从GitHub操作触发“ Git Push Dev”代码将其推向远程服务器。不太确定如何填写我的github动作。我有这个
name: "Build Dev & Release"
on:
push:
paths:
- "**"
- ".github/workflows/my-github-action.yml"
branches:
- authentication
jobs:
pusht-to-dev-server:
???
,但不太确定如何实施“推向dev-server”动作。
编辑:回答给出的答案,我创建了此文件
$ cat .github/workflows/directory-dev.yml
name: "Chicommons Maps Dev: Build & Release"
on:
push:
paths:
- "**"
- ".github/workflows/directory-dev.yml"
branches:
- authentication
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_url: dev.myremote.com:/home/myusername/maps.git
github_token: ${{ secrets.DEPLOY }}
branch: ${{ github.ref }}
,然后创建了此环境,秘密
但是当我推到分支(自动化)时,我会得到此错误
Run ad-m/github-push-action@master
Push to branch refs/heads/authentication
Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}".
I have this remote set up from my local
$ git remote -v
dev [email protected]:/home/myuser/maps.git (fetch)
dev [email protected]:/home/myuser/maps.git (push)
In my remote repo, I have a hook, ~/maps.git/hooks/post-receive, with
# The production directory
TARGET="/var/www/html"
# A temporary directory for deployment
TEMP="/home/myuser/deploy-folder"
# The Git repo
REPO="/home/myuser/maps.git"
# Deploy the content to the temporary directory
mkdir -p $TEMP
#git --work-tree=$TEMP --git-dir=$REPO checkout -f
cd $TEMP
git pull
...
What I would like to do is whenever a PR merges into a particular branch (authentication), I would like to trigger a "git push dev" code push to the remote server from a GitHub action. Not quite sure how to fill in my GitHub action. I have this
name: "Build Dev & Release"
on:
push:
paths:
- "**"
- ".github/workflows/my-github-action.yml"
branches:
- authentication
jobs:
pusht-to-dev-server:
???
but not quite sure how to implement the "push-to-dev-server" action.
Edit: In response to the answer given, I created this file
$ cat .github/workflows/directory-dev.yml
name: "Chicommons Maps Dev: Build & Release"
on:
push:
paths:
- "**"
- ".github/workflows/directory-dev.yml"
branches:
- authentication
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_url: dev.myremote.com:/home/myusername/maps.git
github_token: ${{ secrets.DEPLOY }}
branch: ${{ github.ref }}
and I created this environment encrypted secret
but when I push to my branch (autnentication), I get this error
Run ad-m/github-push-action@master
Push to branch refs/heads/authentication
Missing input "github_token: ${{ secrets.GITHUB_TOKEN }}".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,这将假设
mydomain.remote
是互联网的(而不是仅在本地,在DMZ后面)。这意味着GITHUB服务器(执行GitHub操作/工作流)必须能够查看并联系
myDomain.Remote
。您可以使用
github-push-action
最初是为了推到GitHub存储库,但是您可以更改以包括自己的域服务器。
Note that this would assume
mydomain.remote
is internet-facing (as opposed to on-premise only, behind a DMZ).That means GitHub servers (where the GitHub action/workflow is executed) must be able to see and contact
mydomain.remote
.You can the use the
github-push-action
, initially made to push to a GitHub repository, but that you can change to include your own domain server.