Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Introduction to GitHub Actions
coder7475
coder7475

Posted on

     

Introduction to GitHub Actions

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you toautomate your build, test, and deployment pipeline

Introduction

  • GitHub Actions is aCI/CD pipeline directly integrated with github repository

  • GitHub Actions optimize code-delivery time, from idea to deployment, on a community-powered platform.

  • It allows us toautomate:

    • Running Test Suits
    • Building Images
    • Compiling static sites
    • Deploying code to servers
  • GitHub Actions files are defined asYAML files located in the.github/workflow folder in the repo.

  • GitHub Actions hastemplates that one can use.

  • Can have multipleworkflows in repo triggered by different events.

Tasks to automate

The following tasks are up for automation:

  • Ensure the code passes all unit tests
  • Perform code quality and compliance checks to make sure the source code meets the organization's standards
  • Check the code and its dependencies for known security issues
  • Build the code integrating new source from (potentially) multiple contributors
  • Ensure the software passes integration testsVersion the new build
  • Deliver the new binaries to the appropriate filesystem location
  • Deploy the new binaries to one or more servers
  • If any of these tasks don't pass, report the issue to the proper individual or team for resolution

The Components of GitHub Actions

Components

Explanation of Components

  • GitHub Actionsworkflows can betriggered by events in a repository, such as a pull request or an issue being created.
  • A workflow consists of one or morejobs.
  • Jobs can runsequentially or inparallel.
  • Each job runs in its ownvirtual machine runner or a container.
  • Jobs contain steps that either:
    • Run ascript defined by the user.
    • Run anaction, which is a reusable extension to simplify the workflow.

Workflows

  • 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.

Events

  • An event is a specific activity in a repository that triggers a workflow run.

  • Theon attribute specifies theevent trigger to be used.

  • There are 35+ event triggers:

  • Examples:

    • Pushes: Trigger an action on any push to the repo
    • Pull Request: Run actions when pull request are opened, updated or merged
    • Issues: Execute actions based on issue activities, like creation or labeling
    • Release: Automate workflows when a new release is published
    • Schedule Events: Schedule actions to run at specific times
    • Manual Triggers: Allow manual triggering of actions through the GitHub UI.

Jobs

  • A job is a set of steps in a workflow executed on the same runner.

    • Each step can either be a shell script or an action.
    • Steps are executed sequentially and can share data between them since they run on the same runner.
  • Jobs can be configured to run independently or have dependencies on other jobs. By default, jobs run in parallel unless a dependency is specified.

  • For example, multiple build jobs can run in parallel, and a packaging job can depend on their successful completion.

Actions

  • An action is a reusable application for the GitHub Actions platform that performs complex but repetitive tasks.

  • Actions help reduce repetitive code in workflows, such as setting up the build environment or authentication.

  • You can create custom actions or use actions available in the GitHub Marketplace.

    • There are three types of github actions:
    • Container Actions
    • JavaScript Actions
    • Composite Actions
  • Withcontainer 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.

  • 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 in the cloud or on-premises. JavaScript actions support Linux, macOS, and Windows environments.

  • 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.

Runners

  • A runner is a server that executes workflows when triggered.

  • Each runner runs a single job at a time.

  • GitHub provides runners for Ubuntu Linux, Microsoft Windows, and macOS, each running on a newly provisioned virtual machine.

  • GitHub also offers larger runners for more demanding workloads.

  • Alternatively, you can host your own runners for custom operating systems or specific hardware needs.

Recommendations when using GitHub Actions

  • Review the action'saction.yml file for inputs, outputs, and to make sure the code does what it says it does.

  • Check if the action is in the GitHub Marketplace. This is a good check, even if an action does not have to be on the GitHub Marketplace to be valid.

  • Check if the action is verified in the GitHub Marketplace. This means that GitHub has approved the use of this action. However, you should still review it before using it.

  • Include the version of the action you're using by specifying a Git ref, SHA, or tag

References

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I am a Software Engineer focusing on web development. I am currently exploring the world of DevOps Engineering.
  • Joined

More fromcoder7475

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp