Setting Up GitHub Action Workflow: A Step-by-Step Guide

Step-by-Step Guide on how to Set-Up GitHub Action Workflow

🙋‍♂️ Shubham Verma    🗓 December 2, 2023


Setting Up GitHub Action Workflow: A Step-by-Step Guide


Setting Up GitHub Action Workflow: A Step-by-Step Guide

Workflows are sets of customizable automated processes that you can use to build, test, package, release, and deploy your projects on GitHub. Each workflow is defined by a YAML file in your repository.

What is GitHub Action Workflow?

GitHub Actions is a powerful automation and continuous integration (CI) tool provided by GitHub. Workflows are sets of customizable automated processes that you can use to build, test, package, release, and deploy your projects on GitHub. Each workflow is defined by a YAML file in your repository.

Why You Need GitHub Action Workflow?

GitHub Action Workflows automate your software development lifecycle, streamlining tasks like running tests, building and deploying applications, and more. This automation ensures consistent and reliable processes, leading to faster and more reliable software delivery.
By leveraging GitHub Actions, you can achieve the following benefits:
Continuous Integration (CI):
Automatically build and test your code on every push or pull request.
Continuous Deployment (CD):
Automate the deployment of your application to various environments.
Scheduled Jobs:
Schedule automated tasks, such as database backups or cleanup jobs.
Custom Automation:
Define workflows tailored to your project's specific needs.

Creating the "Initial Workflow" YAML File

Let's set up a basic GitHub Action Workflow named "Initial Workflow" with three jobs: "start," "run_test_cases," and "end." We'll place the workflow definition in the ".github/workflows/InitialWorkflow.yaml" file at the root level of our repository.

Understanding the Codes

name: Initial Workflow
Specifies the name of the workflow.
on:
Defines the events that trigger the workflow. In this case, it triggers on pushes to the "dev" branch, pull requests targeting the "dev" branch, and manual triggers.
jobs:
Defines the jobs that make up the workflow.
start:
runs-on: Specifies the type of runner for this job.
steps:
Defines the sequence of steps for this job, including checking out the repository and running a custom script to echo "Start Initial Workflow."
run_test_cases:
Similar structure as the "start" job but with different steps to run test cases.
end:
Another job with a single step to echo "END Initial Workflow."

Testing the GitHub Action

1. Commit the "InitialWorkflow.yaml" file to your repository.

( Once you will commit your change in dev or merge PR into dev, you can see the action and jobs are is executing)

2. Create a new branch and push the code and raise PR to dev branch, and see the PR. You can see all your action will be triggered and pass and fail accordingly


Setting Up GitHub Action Workflow: A Step-by-Step Guide

Setting Up GitHub Action Workflow: A Step-by-Step Guide

3. Push the code into dev branch or Merge the PR to dev branch.

After pushing into dev or merging the PR into dev, Visit the "Actions" tab on your GitHub repository to see the workflow in action. you can see the action is triggered and jobs are getting executed.
Setting Up GitHub Action Workflow: A Step-by-Step Guide

Setting Up GitHub Action Workflow: A Step-by-Step Guide


Setting Up GitHub Action Workflow: A Step-by-Step Guide

Setting Up GitHub Action Workflow: A Step-by-Step Guide


Jobs in details:

Setting Up GitHub Action Workflow: A Step-by-Step Guide

Conclusion:

GitHub Actions provide a flexible and efficient way to automate your software development workflows. By creating and customizing workflows, you can improve the reliability, speed, and consistency of your development and deployment processes. The example "Initial Workflow" showcased here is just a starting point; you can expand and customize your workflows to meet the specific needs of your project. Experiment with different actions and configurations to optimize your development workflow.

Related Keywords:

Setting Up GitHub Action Workflow: A Step-by-Step Guide

Setting Up GitHub Action Workflow

Quickstart for GitHub Actions

GitHub Actions Tutorial for Beginners

How to build a CI/CD pipeline with GitHub Actions

How To Build Your First GitHub Actions Workflow




Support our IDKBlogs team

Creating quality content takes time and resources, and we are committed to providing value to our readers. If you find my articles helpful or informative, please consider supporting us financially.

Any amount (10, 20, 50, 100, ....), no matter how small, will help us continue to produce high-quality content.

Thank you for your support!




Thank you

I appreciate you taking the time to read this article. The more that you read, the more things you will know. The more that you learn, the more places you'll go. If you’re interested in Node.js or JavaScript this link will help you a lot.

If you found this article is helpful, then please share this article's link to your friends to whom this is required, you can share this to your technical social media groups also. You can follow us on our social media page for more updates and latest article updates.
To read more about the technologies, Please subscribe us, You'll get the monthly newsletter having all the published article of the last month.