add actions #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Push to GitLab | |
on: push | |
jobs: | |
push_gitlab: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # 确保获取完整的仓库历史 | |
- name: Set up Git | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "action@github.com" | |
- name: Push to GitLab | |
run: | | |
# 使用 HTTPS URL 和 PAT | |
git remote add gitlab https://Elflare:${{ secrets.GITLAB_TOKEN }}@gitlab.com/Elflare/zrlong.git | |
git fetch gitlab | |
git push gitlab HEAD:main | |
env: | |
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} # 使用秘密环境变量 |