Test(GitHub Action): 测试GitHub Action #2
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: Sync Repo To GitLab | |
on: | |
push: | |
branches: | |
- main | |
env: | |
SSH_KEY: ${{ secrets.GITLAB_DEPLOY_KEY }} # 服务器私钥 | |
DEPLOY_HOST: ${{ secrets.GITLAB_DEPLOY_HOST }} # 服务器部署地址 | |
DEPLOY_USERNAME: ${{ secrets.GITLAB_DEPLOY_USERNAME }} # 部署用户 | |
DEPLOY_EMAIL: ${{ secrets.GITLAB_DEPLOY_EMAIL }} # 部署邮箱 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Prepare to Gitlab repo | |
run: | | |
git config --global user.name ${{ env.DEPLOY_USERNAME }} | |
git config --global user.email ${{ env.DEPLOY_EMAIL }} | |
git remote add gitlab_mirror ${{ env.DEPLOY_HOST }} | |
- name: Commit files | |
run: | | |
git add -A | |
git commit -m "Sync files from Github repo" | |
- name: Push files | |
env: | |
ssh-key: ${{ env.SSH_KEY }} | |
run: | | |
git push gitlab_mirror main |