First of all, I am quite new to Github Actions.
And I was trying to use Github Actions to automatically push my repo to Gitlab with access token. However, I was always getting error remote: HTTP Basic: Access denied fatal: Authentication failed for 'https://gitlab.com/chuang_/jskara-web.git/'
I tried the solution in GitLab remote: HTTP Basic: Access denied and fatal Authentication, git config --system --unset credential.helper
, but if I put that line in the .yml, it will break and return error code 5. If I don't put that line, I will get the error described above.
My .yml file with tried history: https://github.com/ChuangSheep/javascript-kara-web/blob/master/.github/workflows/pushToGitlab.yml
And here my latest attempt
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