Difference between revisions of "GitHub Actions"

From Christoph's Personal Wiki
Jump to: navigation, search
(Created page with "'''GitHub Actions''' is a service provided by GitHub that allows building continuous integration and continuous deployment (CI/CD) pipelines for testing, releasing, and deploy...")
 
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
'''GitHub Actions''' is a service provided by GitHub that allows building continuous integration and continuous deployment (CI/CD) pipelines for testing, releasing, and deploying software without the use of third-party websites/platforms.
 
'''GitHub Actions''' is a service provided by GitHub that allows building continuous integration and continuous deployment (CI/CD) pipelines for testing, releasing, and deploying software without the use of third-party websites/platforms.
 +
 +
==Introduction==
 +
 +
GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository or deploy merged pull requests to production.
 +
 +
There are different components of GitHub Actions:
 +
 +
;Workflows : A workflow is a configurable automated process that will run one or more jobs.
 +
;Events : An event is a specific activity in a repository that triggers a workflow run. For example, activity can originate from GitHub when someone creates a pull request, opens an issue, or pushes a commit to a repository.
 +
;Jobs : A job is a set of steps in a workflow
 +
;Actions : Performs frequently repeated task. An action can for example pull your git repository from GitHub,
 +
;Runners : A runner is a server that runs your workflows when they’re triggered.
  
 
==Examples==
 
==Examples==
Line 20: Line 32:
 
       - name: multiline script  
 
       - name: multiline script  
 
         run: |
 
         run: |
          node -v  
+
          node -v  
          npm -v
+
          npm -v
 
       - name: python command  
 
       - name: python command  
 
         run: |
 
         run: |
Line 28: Line 40:
 
           (platform.processor())
 
           (platform.processor())
 
         shell: python
 
         shell: python
 +
</pre>
 +
 +
* Using the GitHub CLI:
 +
<pre>
 +
$ gh workflow view
 +
? Select a workflow Shell Commands (simple.yaml)
 +
Shell Commands - simple.yaml
 +
ID: 13613098
 +
 +
Total runs 1
 +
Recent runs
 +
✓  initial commit of .github/workflows/simple.yaml  Shell Commands  master  push  1280462255
 +
 +
To see more runs for this workflow, try: gh run list --workflow simple.yaml
 +
To see the YAML for this workflow, try: gh workflow view simple.yaml --yaml
 +
 +
$ gh workflow view simple.yaml --yaml
 +
Shell Commands - simple.yaml
 +
ID: 13613098
 +
 +
name: Shell Commands
 +
 +
on: [push]
 +
 +
jobs:
 +
  run-shell-command:
 +
    runs-on: ubuntu-latest
 +
    steps:
 +
      - name: echo a string
 +
        run: echo "Hello World"
 +
      - name: multiline script
 +
        run: |
 +
          node -v
 +
          npm -v         
 +
      - name: python Command
 +
        run: |
 +
          import platform
 +
          print
 +
          (platform.processor())         
 +
        shell: python
 +
 +
 +
$ gh run list --workflow simple.yaml
 +
STATUS  NAME                                            WORKFLOW        BRANCH  EVENT  ID          ELAPSED  AGE
 +
✓      initial commit of .github/workflows/simple.yaml  Shell Commands  master  push  1280462255  15s      15d
 +
 +
For details on a run, try: gh run view <run-id>
 +
 +
$ gh run view 1280462255
 +
 +
✓ master Shell Commands · 1280462255
 +
Triggered via push about 16 days ago
 +
 +
JOBS
 +
✓ run-shell-command in 1s (ID 3726651254)
 +
 +
For more information about a job, try: gh run view --job=<job-id>
 +
View this run on GitHub: https://github.com/christophchamp/github-actions/actions/runs/1280462255
 
</pre>
 
</pre>
  
 
==External links==
 
==External links==
 
* [https://docs.github.com/en/actions Official GitHub Actions documentation]
 
* [https://docs.github.com/en/actions Official GitHub Actions documentation]
 +
* [https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions Understanding GitHub Actions]
 
* [https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners About GitHub-hosted runners]
 
* [https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners About GitHub-hosted runners]
 
* [https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging Enabling debug logging]
 
* [https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging Enabling debug logging]
 
* [https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md List of packages installed on Ubuntu by default]
 
* [https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md List of packages installed on Ubuntu by default]
 
* [https://github.com/christophchamp/github-actions Christoph Champ's GitHub Actions demos]
 
* [https://github.com/christophchamp/github-actions Christoph Champ's GitHub Actions demos]
 +
* [https://marketplace.visualstudio.com/items?itemName=me-dutour-mathieu.vscode-github-actions GitHub Actions YAML Extension] &mdash; for VS Code
 +
 +
===GitHub CLI===
 +
* [https://cli.github.com/manual/ GitHub CLI Online Manual]
 +
* [https://github.blog/2021-04-15-work-with-github-actions-in-your-terminal-with-github-cli/ Work with GitHub Actions in your terminal with GitHub CLI]
  
 
[[Category:DevOps]]
 
[[Category:DevOps]]

Latest revision as of 23:08, 26 September 2022

GitHub Actions is a service provided by GitHub that allows building continuous integration and continuous deployment (CI/CD) pipelines for testing, releasing, and deploying software without the use of third-party websites/platforms.

Introduction

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository or deploy merged pull requests to production.

There are different components of GitHub Actions:

Workflows 
A workflow is a configurable automated process that will run one or more jobs.
Events 
An event is a specific activity in a repository that triggers a workflow run. For example, activity can originate from GitHub when someone creates a pull request, opens an issue, or pushes a commit to a repository.
Jobs 
A job is a set of steps in a workflow
Actions 
Performs frequently repeated task. An action can for example pull your git repository from GitHub,
Runners 
A runner is a server that runs your workflows when they’re triggered.

Examples

Basic

$ cat .github/workflows/basic.yaml

name: Shell Commands 

on: [push]

jobs:
  run-shell-commands:
    runs-on: ubuntu-latest
    steps: 
      - name: echo a string
        run: echo "Hello, World!"
      - name: multiline script 
        run: |
          node -v 
          npm -v
      - name: python command 
        run: |
          import platform 
          print
          (platform.processor())
        shell: python
  • Using the GitHub CLI:
$ gh workflow view
? Select a workflow Shell Commands (simple.yaml)
Shell Commands - simple.yaml
ID: 13613098

Total runs 1
Recent runs
✓  initial commit of .github/workflows/simple.yaml  Shell Commands  master  push  1280462255

To see more runs for this workflow, try: gh run list --workflow simple.yaml
To see the YAML for this workflow, try: gh workflow view simple.yaml --yaml

$ gh workflow view simple.yaml --yaml
Shell Commands - simple.yaml
ID: 13613098

name: Shell Commands 

on: [push]

jobs:
  run-shell-command:
    runs-on: ubuntu-latest
    steps: 
      - name: echo a string
        run: echo "Hello World"
      - name: multiline script 
        run: |
           node -v 
           npm -v           
      - name: python Command 
        run: |
          import platform 
          print
          (platform.processor())          
        shell: python


$ gh run list --workflow simple.yaml
STATUS  NAME                                             WORKFLOW        BRANCH  EVENT  ID          ELAPSED  AGE
✓       initial commit of .github/workflows/simple.yaml  Shell Commands  master  push   1280462255  15s      15d

For details on a run, try: gh run view <run-id>

$ gh run view 1280462255

✓ master Shell Commands · 1280462255
Triggered via push about 16 days ago

JOBS
✓ run-shell-command in 1s (ID 3726651254)

For more information about a job, try: gh run view --job=<job-id>
View this run on GitHub: https://github.com/christophchamp/github-actions/actions/runs/1280462255

External links

GitHub CLI