Introducing GitHub Workflow

GitHub Actions is GitHub's continuous integration/continuous deployment (CI/CD) service. It allows you to automate software workflows such as running tests, deploying software to production, executing scripts on a regular basis, etc. The main component of GitHub Actions is the workflow (Workflow), you can .github/workflowsdefine one or more workflows in the directory in the GitHub repository.

A workflow is composed of one or more "jobs" (Jobs), each of which can be executed in parallel or sequentially in the same or different operating environments. A job is composed of a series of "steps" (Steps), these steps will be executed in the same environment in a defined order.

Each step can execute commands (such as shell commands or scripts), or use predefined tasks called "Actions". These Actions can be created and shared by GitHub, the repository's maintainer, or anyone else. For example, there are Actions to check out code, set up a Node.js environment, deploy to AWS, and more.

The running of the GitHub workflow can be triggered by various events, such as pushing to the warehouse, creating a Pull Request, timing triggering (using cron syntax), manual triggering, etc.

GitHub workflows are written in YAML syntax and stored in .github/workflowsthe directory of the project repository.

For example, here's a simple GitHub workflow that runs a Node.js "Hello, World!" script on Ubuntu when someone pushes to the master branch:

name: My Workflow

on:
  push:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Use Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '14'

    - name: Run Hello, World!
      run: |
        echo "console.log('Hello, World!');" > index.js
        node index.js

This is just a very basic example. The actual GitHub workflow can be more complex, including multiple tasks, multiple steps, using various predefined Actions, calling external services, and so on.

Guess you like

Origin blog.csdn.net/m0_57236802/article/details/131619167