Github Actions Tutorial: Push and run python code to a remote warehouse

I own a site, this site will use a python script to generate.

DETAILED python is generated script reads csv file in the directory, each row of data will be parsed into fixed format, and generates html files Finally the modified file to automatically push github

Of course, all of the above steps are implemented automation, summarized as follows:

  1. My local modifications csv file, then push to github
  2. I push operation triggers a realization set a good action

action code is set as follows:

name: Python application

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: checkout actions
    - uses: actions/checkout@v1

    - name: Set up Python 3.7
      uses: actions/setup-python@v1
      with:
        python-version: 3.7
        
    - name: Update paper list
      run: |
        cd paper_infos
        python generate_tables.py
        
    - name: commit
      run: |
        git config --global user.email [email protected]
        git config --global user.name marsggbo
        git add .
        git commit -m "update" -a
        
    - name: Push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}

Code explanation:

  • The first line name: Whatever can be set, is your action name
  • on: Trigger condition, I set here is pushthe event to start operation
  • jobs: Github Actions hierarchy is this: workflow / jobs / steps / action. Note to distinguish action and Github Actions in the Actions area, the two are different concepts, action it means the lowest level of action, Actions is the name of a function to Github we provide it.
  • steps: And similar jobs. You can see a number of steps by the step, each step can be setname
  • uses: This indication someone else pre-set Actions, such as the code I use to python, so I used actions/setup-python@v1to set the python environment, I do not set myself up.
  • run: A specific line of code to run what commands
    • It can be seen in my name for the first Update paper listrun the python script
    • After github folder did commit
    • Finally, the use of someone else's actions the updated code push to github again
  • The last line github_tokenshould be noted that this long pause before I get to understand this fact, it is equivalent to your password. This setting is to set up access to your personal page (ie, Settings, not a warehouse Settings), select Developer settings> Personal access tokens> Generate new token, is set to name GITHUB_TOKEN, and then check the repo, admin:repo_hook, workflowand other options, and finally click Generate tokencan be.

See specific code marsggbo / automl_a_survey_of_state_of_the_art



MARSGGBO Original


If interested, welcome private stamp

E-mail: [email protected]


2019-12-24 11:25:45



Guess you like

Origin www.cnblogs.com/marsggbo/p/12090703.html