{{announcement.body}}
{{announcement.title}}

Configure GitHub Actions With CI/CD in Any Cloud, Language, and OS

DZone 's Guide to

Configure GitHub Actions With CI/CD in Any Cloud, Language, and OS

Github Action is now able to integrate into your CI/CD pipeline. Check out this example with Docker images.

· Cloud Zone ·
Free Resource
With GitHub Actions, your pipeline works more smoothly than ever.

Introduction

GitHub Actions now make it easier to automate the process build, test, and deploy projects on any platform, including Linux, macOS, and Windows. Run workflows in a container or in a virtual machine. Actions also supports more languages and frameworks including Node.js, Python, Java, PHP, Ruby, C/C++, .NET, Android, and iOS. Testing multi-container apps? You can now test your web service and its database together by simply adding some docker-compose to workflow file.

You may also enjoy:  Can GitHub Actions Replace Your CI Server?

Matrix Builds

Matrix builds make it easy to test multiple versions of the project in parallel. Add a few lines to the Actions YAML file, and let GitHub take care of the rest.

name: Node CI 
on: [push] 
jobs:
  build:
     runs-on: ubuntu-latest
     strategy:
      matrix:
        node-version: [12.x]
     steps:
     - uses: actions/checkout@v1
     - name: Use Node.js ${{ matrix.node-version }}
       uses: actions/setup-node@v1
       with:
        node-version: ${{ matrix.node-version }}
     - name: npm install, build, and test
       run: |
         npm install
         npm run build --if-present
         npm test
       env:
         CI: true

Workflow Live Logs

Live logs provide rich feedback into the progress of builds as they run. GitHub streams logs to the Actions console to show status in real-time. Logs are formatted for easy reading, color format and including emojis. Live logs with numbering makes it easy to discuss a build failure or test result with a friend or colleague.


Workflow Live logs
Workflow Live logs

Automate Workflows on GitHub Events

GitHub Actions helps you build, test, and deploy applications, but you can also use it to automate other tasks common to your developer workflows: prioritize and managing issues, automating releases, collaborating with your user base, and more. Actions workflows can be triggered on events from across the developer life cycle on GitHub. Any GitHub App can now add its own custom events, so developers and partners can customize GitHub to meet the needs of any project.

Built-in Secret Store

Automate your software development practices with workflow files embracing the Git flow by codifying it in your repository.

Build on An Integrated Package and Container Registry

Publishing packages and containers are a key part of any CI/CD workflow, such as open-source libraries or deploying a large web service. GitHub Actions make it easy to publish and consume packages from GitHub Package Registry or any other registry. As developers gain access to Actions, they’ll also have access to GitHub Package Registry before general availability to automate entire workflows across issues and code, from build to deployment.

Suggested Workflows Make It Easy to Get Started

We want to make it as easy as possible for you to get started with CI/CD. Now when you enable Actions for your repository, GitHub will suggest Actions workflows that are appropriate for your project.

Suggested Workflows
Suggested Workflows

Simple, Pay-As-You-Go Pricing

We want every open source project to be productive and use best practices, so Actions is free for the 40 million developers on GitHub to use with public repositories. For private repositories, Actions offers simple, pay-as-you-go pricing. If you want to run on your own hardware or another cloud, our self-hosted runners are free to use. And during the beta, Actions are free for everyone. For full details, see the pricing section on the signup page.

Pricing
Pricing

Instructions to Build and Push a Docker Image Into a Docker Hub

  1. Select the GitHub Repository and click on fork button on the top right corner and select the account where the repo needs to be forked.
  2. Click on the Actions tab.
Actions tab
Actions tab

3. GitHub Actions automatically suggests workflows or you may select one based on your requirements.

4. Select the Docker workflow in the popular Continuous integrations workflows section and click set up this workflow.


Docker image workflow
Docker image workflow

5. This automatically creates a workflow in YAML format. Customize that workflow based on requirements.


Docker Image YAML
Docker Image YAML

6. After you've customized the workflow, click on Start commit. Add a commit message and click commit changes.


Commit new file
Commit new file

7. Automatically start CI. Click on the Actions tab and select Running workflow.


Starting CI
Starting CI

8. Click on that running workflow to see each and every step live Streaming logs.


Updated yaml
Updated yaml


9. Once the job is completed you are able to search the logs based on the keywords if you want.

10. Log in to your Docker Hub account.


Docker sign in
Docker sign in page


11. Search for repository created in step 5, click on the repository.

Docker repository search
Docker repository search

12. Run the image in a container

docker run -d -p 4001:4000 krishnaprasadkv/hello-world:latest


Running the image in container
Running the image in container

13. View the new container:

docker ps -a


View container
View container

14. Go to browser and open http://localhost:4001/

View hello world
View hello world

Further Reading

Build Pipelines for GitHub Projects

Git Strategies for Software Development: Part 1

Topics:
cloud ,docker ,dockerhub ,git and github ,github actions ,open source ,tutorial

Published at DZone with permission of Krishna Prasad Kalakodimi . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}