使用Github Actions使用访问令牌推送到Gitlab



首先,我对Github Actions还很陌生。

我试图使用Github Actions自动将我的回购推送到带有访问令牌的Gitlab。然而,我总是收到错误remote: HTTP Basic: Access denied fatal: Authentication failed for 'https://gitlab.com/chuang_/jskara-web.git/'

我在GitLab remote中尝试了解决方案:HTTP Basic:Access denied and fatal Authentication,git config --system --unset credential.helper,但如果我把那一行放在.yml中,它会中断并返回错误代码5。如果我不放那条线,我会得到上面描述的错误。

我的带有试用历史记录的.yml文件:https://github.com/ChuangSheep/javascript-kara-web/blob/master/.github/workflows/pushToGitlab.yml

这是我最近一次尝试

name: PushGitlab
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with: 
fetch-depth: 0
env: 
token: ${{ secrets.GITLAB_ACCESS_TOKEN }}
- name: Push To Gitlab
run: |
echo Starting to push repo to gitlab
git config user.name "ChuangSheep"
git config user.email "44814054+ChuangSheep@users.noreply.github.com"
git remote set-url origin "https://oauth2:${token}@gitlab.com/chuang_/jskara-web.git"
git push origin master

尝试将带有标记的env块移动到";推送到Gitlab"步当前您将远程url设置为https://oauth2:@gitlab.com/chuang_/jskara-web.git,因为从未设置token变量。

最新更新