"Getting Started with GitHub Actions: Exploring Automation and CI/CD Workflows with a Demo Project"

"Getting Started with GitHub Actions: Exploring Automation and CI/CD Workflows with a Demo Project"

ยท

4 min read

Welcome to our GitHub Actions Demo Project! ๐Ÿš€ Explore the magic of automation as we unravel the capabilities of GitHub Actions. In this brief journey, we'll break down the code you've provided, revealing how these actions orchestrate seamless workflows, check code quality, and ensure the reliability of your software. Let's dive in and uncover the hidden potential of streamlined development with GitHub Actions!

First, open a new tab in your browser and search for "GitHub Action Docs" And select "Quickstart"

On Quickstart Page we will be getting steps to create our first GitHub action workflow

Now, Open the terminal or in VS Code editor create a folder named " GitHub action demo" and Run the "git init" command

Next, create the folder " .github" and inside the .github folder create another folder named "workflows"

Next, inside the workflow folder create a " github-action-demo.yml" file

YAML files in GitHub Actions are configuration files. They are used to define the workflows, jobs, and steps that make up your automated processes within GitHub Actions.

Next, using the Vim editor we will add code to the YAML file

If you are using a code editor we won't need to use Vim we can directly create a YAML file and add code, here I am using the terminal working space approach.

And don't worry about the YAML file the same code can be found in the "GitHub docs" Quickstart page

name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions ๐Ÿš€
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "๐ŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "๐Ÿง This job is now running on a ${{ runner.os }} server hosted by GitHub!"
      - run: echo "๐Ÿ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "๐Ÿ’ก The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "๐Ÿ–ฅ๏ธ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}
      - run: echo "๐Ÿ This job's status is ${{ job.status }}."

Next, Login to your GitHub account and create a New Repository as same named our demo project folder

Next, after creating the repo just copy the repo link and go back to the terminal, and here git add and commit all the files and after that, we will make the "main" branch default and we will add a git remote with our repo link and push the code to GitHub.

The command git branch -M main is used in Git to rename the default branch of a repository from its previous name (usually master) to a new name, in this case, main.

Our code is being pushed to GitHub

Now, select "Actions"

As we can see our first workflow ran successfully and on the left hand under "All workflows" we can see our "GitHub action demo" workflow

Click on the workflow and see and check all the steps performed

Now, let's create a New branch and push those changes to Git Hub.

Here, we created a new branch " demo " and created a file named " name.txt" Inside the file, we add my name to it using the command.

echo "your name" > name.txt

Now, as we made some changes we need to git add and commit to those new changes after that we push our change with the demo branch to GitHub

Here, our new branch and changes have been pushed successfully and now we will create a " pull request" Simply click on " compare & pull request"

Select "Create pull request"

Select " Merge pull request "

And finally, select "confirm merge"

Merge is complete and we can see our change has passed Github Action

And if go to Actions we can see our multiple workflows which get triggers after every push and commits

Select the latest workflow and check the steps

we can go through every step and see a list of jobs it performed

Here we can see our " List files in the repository" showing our name.txt, which was pushed by the demo branch and later merged into the main branch.

In conclusion, our GitHub Actions Demo Project offers a firsthand glimpse into the world of automation and continuous integration. By dissecting the provided code, we've unveiled the orchestration of streamlined workflows, code quality checks, and reliability assurance โ€“ all powered by GitHub Actions. This hands-on exploration equips you with the knowledge to harness automation's potential, fostering efficient development, collaboration, and code excellence.

Thank you for reading the blog!!!!!

ย