|
1 | 1 | # explore-github-action |
2 | | -Explore GitHub Workflow |
3 | | -**Workflow**: |
4 | | - The overall automated process that defines when and how different actions should be executed, triggered by events like pushing code to a repository or creating a pull request. |
5 | | -**Action**: |
6 | | - An individual, modular step within a workflow, performing a specific task like running a unit test, deploying to a server, or checking code quality. |
7 | | -**How they work together**: |
8 | | -YAML configuration: |
9 | | -Both workflows and actions are defined using YAML syntax within the **.github/workflows** directory in your repository. |
10 | | -Combining actions: |
11 | | - You can combine multiple actions from either the GitHub community or custom-built actions to create a complex workflow. |
12 | | -Triggering workflows: |
13 | | - A workflow can be triggered by various events like pushing code, creating a pull request, or a scheduled time. |
14 | | - |
15 | | -**A workflow must contain the following basic components:** |
16 | | -1. One or more events that will trigger the workflow. |
17 | | -2. One or more jobs, each of which will execute on a runner machine and run a series of one or more steps. |
18 | | -3. Each step can either run a script that you define or run an action, which is a reusable extension that can simplify your workflow. |
19 | | - |
20 | | -**A workflow trigger is an event that causes a workflow to run. There are four types of triggers:** |
21 | | -1. Events happening in the workflow’s GitHub repository. |
22 | | -2. Events occurring outside of GitHub, which trigger a repository_dispatch event in GitHub. |
23 | | -3. A predefined schedule. |
24 | | -4. Manual trigger |
25 | | - |
26 | | - ## Notes:- |
27 | | - - GitHub Actions is a powerful automation platform that goes far beyond just CI/CD. While automating the CI/CD pipeline is one of the most popular use cases, |
28 | | - - A GitHub Actions workflow is a process that you set up in your repository to automate software-development lifecycle tasks, including GitHub Actions |
29 | | - - A "GitHub workflow" refers to a series of automated tasks defined in a YAML file within a GitHub repository, essentially a blueprint for a continuous integration and continuous delivery (CI/CD) pipeline, while a "GitHub action" is a single, reusable task within that workflow, like running a specific test or building a project, which can be combined to create a larger automated process. |
30 | | - - A "GitHub workflow" refers to a series of automated tasks defined in a YAML file within a GitHub repository, essentially a blueprint for a continuous integration and continuous delivery (CI/CD) pipeline, while a "GitHub action" is a single, reusable task within that workflow, like running a specific test or building a project, which can be combined to create a larger automated process. |
31 | | - - GitHub Actions are packaged scripts to automate tasks in a software-development workflow in GitHub. |
32 | | - - Ensure the code passes all unit tests. |
33 | | - - Perform code quality and compliance checks to make sure the source code meets the organization's standards. |
34 | | - - Check the code and its dependencies for known security issues. |
35 | | - - Build the code integrating new source from (potentially) multiple contributors. |
36 | | - - Ensure the software passes integration tests. |
37 | | - - Version the new build. |
38 | | - - Deliver the new binaries to the appropriate filesystem location. |
39 | | - - Deploy the new binaries to one or more servers. |
40 | | - - If any of these tasks don't pass, report the issue to the proper individual or team for resolution. |
41 | | - |
42 | | - |
43 | | -**Types of GitHub actions** |
44 | | -There are three types of GitHub actions: |
45 | | -- Container actions |
46 | | -- JavaScript actions |
47 | | -- Composite actions. |
48 | | - |
49 | | -With container actions, the environment is part of the action's code. These actions can only be run in a Linux environment that GitHub hosts. Container actions support many different languages. |
50 | | - |
51 | | -JavaScript actions don't include the environment in the code. You'll have to specify the environment to execute these actions. You can run these actions in a VM (virtual machine) in the cloud or on-premises. JavaScript actions support Linux, macOS, and Windows environments. |
52 | | - |
53 | | -Composite actions allow you to combine multiple workflow steps within one action. For example, you can use this feature to bundle together multiple run commands into an action, and then have a workflow that executes the bundled commands as a single step using that action. |
54 | | - |
55 | | -A workflow must have at least one job. A job is a section of the workflow associated with a runner. A runner can be GitHub-hosted or self-hosted, and the job can run on a machine or in a container. |
56 | | - |
57 | | -**Workflows** |
58 | | - A workflow is an automated process that you add to your repository. A workflow needs to have at least one job, and different events can trigger it. You can use it to build, test, package, release, or deploy your repository's project on GitHub. |
59 | | - |
60 | | -**Jobs** |
61 | | - The job is the first major component within the workflow. A job is a section of the workflow that will be associated with a runner. A runner can be GitHub-hosted or self-hosted, and the job can run on a machine or in a container. You'll specify the runner with the runs-on: attribute. Here, you're telling the workflow to run this job on ubuntu-latest. We'll talk more about runners in the next unit. |
62 | | - |
63 | | -**Steps** |
64 | | - A step is an individual task that can run commands in a job. In our preceding example, the step uses the action actions/checkout@v2 to check out the repository. What's interesting is the uses: ./action-a value. This is the path to the container action that you'll build in an action.yml file. |
65 | | - |
66 | | -**Actions** |
67 | | - The actions inside your workflow are the standalone commands that are executed. These standalone commands can reference GitHub actions such as using your own custom actions, or community actions like the one we use in the preceding example, actions/checkout@v2. You can also run commands such as run: npm install -g bats to execute a command on the runner. |
68 | | -https://learn.microsoft.com/en-us/training/modules/github-actions-automate-tasks/2c-configure-github-actions-workflow |
69 | | - |
70 | | -[](https://github.com/manojkumar-jmp/explore-github-action/actions/workflows/hello-workflow.yml) |
| 2 | + |
| 3 | +Simple examples of GitHub Workflows, Jobs, Steps, and Actions. Learn how to automate CI/CD and other tasks using GitHub Actions. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This repository provides easy-to-understand examples demonstrating how to use GitHub Actions to automate tasks such as building, testing, and deploying your code. It is intended for beginners and anyone interested in getting started with CI/CD and automation using GitHub Actions. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- Example workflow files for typical CI/CD pipelines |
| 12 | +- Demonstrates the structure of workflows, jobs, steps, and actions |
| 13 | +- Shows how to use both built-in and custom actions |
| 14 | +- Clear, commented YAML files for easy learning |
| 15 | + |
| 16 | +## Getting Started |
| 17 | + |
| 18 | +1. **Fork or clone this repository:** |
| 19 | + ```bash |
| 20 | + git clone https://github.com/manojkumar-jmp/explore-github-action.git |
| 21 | + ``` |
| 22 | + |
| 23 | +2. **Browse the `.github/workflows/` directory** to see ready-to-use workflow files. |
| 24 | + |
| 25 | +3. **Adapt the examples** to your own repositories and automation needs. |
| 26 | + |
| 27 | +## Example |
| 28 | + |
| 29 | +Below is a basic example of a workflow that runs on every push and prints "Hello, world!": |
| 30 | + |
| 31 | +```yaml |
| 32 | +name: Hello World Workflow |
| 33 | + |
| 34 | +on: [push] |
| 35 | + |
| 36 | +jobs: |
| 37 | + say-hello: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - name: Print greeting |
| 41 | + run: echo "Hello, world!" |
| 42 | +``` |
| 43 | +
|
| 44 | +Find more examples in the [`.github/workflows/`](.github/workflows/) directory. |
| 45 | + |
| 46 | +## Documentation |
| 47 | + |
| 48 | +- [GitHub Actions Documentation](https://docs.github.com/en/actions) |
| 49 | +- [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) |
| 50 | + |
| 51 | +## Contributing |
| 52 | + |
| 53 | +Contributions are welcome! Please open issues or pull requests for improvements or new examples. |
| 54 | + |
| 55 | +## License |
| 56 | + |
| 57 | +This repository is licensed under the MIT License. |
0 commit comments