Skip to main content

Command Palette

Search for a command to run...

The first GitHub Actions

Published
โ€ข2 min read
P

๐‘ช๐’๐’๐’–๐’… ๐’‚๐’๐’… ๐‘ซ๐’†๐’—๐‘ถ๐’‘๐’” ๐‘ป๐’†๐’„๐’‰ ๐‘ช๐’๐’Ž๐’Ž๐’–๐’๐’Š๐’•๐’š || ๐‘ท๐’“๐’๐‘ซ๐’†๐’—๐‘ถ๐’‘๐’”๐‘ฎ๐’–๐’š ๐Ÿค– https://t.me/prodevopsguy ๐Ÿ‘‹ Hi there! We are ProDevOpsGuy, a passionate DevOps enthusiast Tech Community with a strong belief in the power of automation and collaboration to drive innovation. ๐Ÿš€ I thrive in bridging the gap between development and operations, creating seamless and efficient software delivery pipelines. My journey in the world of DevOps has allowed me to blend my technical skills with a knack for problem-solving, enabling me to contribute effectively to agile and dynamic environments. ๐Ÿ’ก With a keen interest in continuous integration, continuous delivery (CI/CD), containerization, and orchestration, I've had the privilege to explore cutting-edge technologies like Docker, Kubernetes, Jenkins, and Ansible. I find joy in designing scalable and resilient infrastructures that enable teams to deploy applications faster and with greater confidence. ๐ŸŒ Beyond the tech realm, I'm an advocate for DevOps culture, emphasizing collaboration, communication, and a relentless pursuit of improvement. I'm always eager to connect with fellow professionals, exchange insights, and explore opportunities to collaborate on exciting projects. ๐Ÿ“š When I'm not tinkering with the latest DevOps tools, you can find me indulging in books on technology trends, hiking to rejuvenate, and occasionally experimenting with new coding challenges. ๐ŸŒŸ Let's connect! Whether you're looking to discuss DevOps methodologies, explore partnership opportunities, or simply share experiences, feel free to reach out. I'm excited to be part of the DevOps journey, driving excellence together.

1. Introduction

GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.

To get more details about GitHub Actions you can see About GitHub Actions

2. Let's start

Make sure that you register Github Actions beta program and also receive an approval email from Github like "Youโ€™re in! Get started with GitHub Actions beta"...

In this tutorial, I use my repository called React Starter Kit.

Don't talk any more, go go go...

Step 1: Go to your repository and click on the "Actions" tab

Step 2: Click the button "Set up a workflow yourself"

You will see the template below:

name: CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Run a one-line script
      run: echo Hello, world!
    - name: Run a multi-line script
      run: |
        echo Add other actions to build,
        echo test, and deploy your project.

Step 3: Edit the template

Following the Workflow syntax for GitHub Actions
and Set up your GitHub Actions workflow with a specific version of node.js

I edit my first actions like below:

name: CI

on: [push]

jobs:
  build:
    name: Build
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        node_version: [10, 12]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node_version }}
      uses: actions/setup-node@v1
      with:
        version: ${{ matrix.node_version }}

    - name: yarn install, yarn lint, yarn test, yarn build
      run: |
        yarn install
        yarn lint
        yarn test
        yarn build

Explanation:
In the configuration above

  • GitHub Actions will trigger on push event on any branch

  • It will use Ubuntu 18.04 runs-on: ubuntu-18.04

  • It will run 2 times on 2 node versions: node_version: [10, 12]

  • It will use yarn to run instead of npm

  • It will run yarn install, yarn lint, yarn test, yarn build

For further commands please refer to the Workflow syntax for GitHub Actions

Step 4: Waiting and getting the result!

Github Actions build result

It works fine!!!

3. In conclusion

So easy to create a simple pipeline with GitHub Actions. It will help you build your project without using any external CI/CD like Circle CI or something like that.

If you find this article helpful then you can buy me a coffee.

Follow for more stories like this ๐Ÿ˜Š/ GitHub.

More from this blog

P

ProDevOpsGuy Tech Community

73 posts

Home of DevOps Best Blogs/Series