仓库文件夹备份

  1. name: CI
  2. on: [watch]
  3. jobs:
  4. build:
  5. runs-on: ubuntu-latest
  6. steps:
  7. - uses: actions/checkout@v2
  8. - name: 配置Git
  9. run: |
  10. git config --global user.name 'wztlink1013'
  11. git config --global user.email '2550374815@qq.com'
  12. - name: 在云端进行复制文件夹操作
  13. env:
  14. Github_Token: ${{ secrets.TOKEN_GITHUBAPI }}
  15. run: |
  16. git clone https://${Github_Token}@github.com/wztlink1013/website-source website-source
  17. cd website-source
  18. cp -r ./Secret文集/ ./backup/
  19. git status
  20. git add .
  21. git commit -m "backup"
  22. git push --force --quiet "https://${Github_Token}@github.com/wztlink1013/website-source" master:master

博客CICD腾讯云函数

Python2.7执行环境

  1. # -*- coding: utf8 -*-
  2. import requests
  3. def main_handler(event, context):
  4. r = requests.post("https://api.github.com/repos/wztlink1013/Blog3.0/dispatches",
  5. json={'event_type': "run-it"},
  6. headers = {"User-Agent":'curl/7.52.1',
  7. 'Content-Type': 'application/json',
  8. 'Accept': 'application/vnd.github.everest-preview+json',
  9. 'Authorization': 'token **********'})
  10. if r.status_code == 204:
  11. return "This's OK!"
  12. else:
  13. return r.status_code

触发器设置

GitHub Actions代码汇总 - 图1

博客CICD阿里云函数

Python3执行环境

  1. # -*- coding: utf-8 -*-
  2. import logging
  3. import requests
  4. OK = b'ok\n'
  5. def handler(environ, start_response):
  6. status = '200 OK'
  7. response_headers = [('Content-type', 'text/plain')]
  8. sync_yuque()
  9. start_response(status, response_headers)
  10. return [OK]
  11. def sync_yuque():
  12. requests.post("https://api.github.com/repos/wztlink1013/Blog3.0/dispatches",
  13. json={'event_type': "run-it"},
  14. headers={"User-Agent":'curl/7.52.1',
  15. 'Content-Type': 'application/json',
  16. 'Accept': 'application/vnd.github.everest-preview+json',
  17. 'Authorization': 'token *********'})