GitHubのあれこれ

GraphQL API, Actions, etc...

Index

GitHub GraphQL API

GitHub 上にあるissueやcommitなどのデータを柔軟に取得できる

query($number_of_repos:Int!) {
  viewer {
    name
     repositories(last: $number_of_repos) {
       nodes {
         name
       }
     }
   }
}
variables {
   "number_of_repos": 3
}

demo

GitHub Actions

GitHub が提供するCI/CDサービス

特徴

public レポジトリでの動作は無料

Marketplace

GitHubアカウントだけで完結

GitHub Actions でCIを高速化する - Docker

  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: docker/setup-buildx-action@v1
      - uses: docker/build-push-action@v2
        with:
          file: Dockerfile
          context: ./
          tags: foo
          target: development
          load: true # 後ろの処理でdocker runするなら必要
          cache-from: type=gha
          cache-to: type=gha,mode=max

Pythonのマルチステージビルドが90sec -> 20sec

GitHub Actions でCIを高速化する - Python

  cached-poetry:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install poetry
        run: pipx install poetry
      - uses: actions/setup-python@v4
        with:
          python-version: "3.10"
          cache: "poetry"
      - run: poetry install

poetry installが 20sec -> 1sec未満

キャッシュを有効にするサンプル

- [C# - NuGet](#c---nuget)
- [Clojure - Lein Deps](#clojure---lein-deps)
- [D - DUB](#d---dub)
  - [POSIX](#posix)
  - [Windows](#windows)
- [Deno](#deno)
  - [Linux](#linux)
  - [macOS](#macos)
  - [Windows](#windows-1)
- [Elixir - Mix](#elixir---mix)
- [Erlang - Rebar3](#erlang--rebar3)
- [Go - Modules](#go---modules)
  - [Linux](#linux-1)
  - [macOS](#macos-1)
  - [Windows](#windows-2)
- [Haskell - Cabal](#haskell---cabal)
- [Haskell - Stack](#haskell---stack)
- [Java - Gradle](#java---gradle)
- [Java - Maven](#java---maven)
- [Node - npm](#node---npm)
- [Node - Lerna](#node---lerna)
- [Node - Yarn](#node---yarn)
- [Node - Yarn 2](#node---yarn-2)
- [OCaml/Reason - esy](#ocamlreason---esy)
- [PHP - Composer](#php---composer)
- [Python - pip](#python---pip)
  - [Simple example](#simple-example)
  - [Multiple OS's in a workflow](#multiple-oss-in-a-workflow)
  - [Multiple OS's in a workflow with a matrix](#multiple-oss-in-a-workflow-with-a-matrix)
  - [Using pip to get cache location](#using-pip-to-get-cache-location)
- [Python - pipenv](#python---pipenv)
- [R - renv](#r---renv)
- [Ruby - Bundler](#ruby---bundler)
- [Rust - Cargo](#rust---cargo)
- [Scala - SBT](#scala---sbt)
- [Swift, Objective-C - Carthage](#swift-objective-c---carthage)
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
- [Swift - Swift Package Manager](#swift---swift-package-manager)

https://github.com/actions/cache/blob/main/examples.md

他のCI tool からの移行もできる

https://github.com/github/gh-valet

 

Valet helps facilitate the migration of Azure DevOps, CircleCI, GitLab CI, Jenkins, and Travis CI pipelines to GitHub Actions.

Made with Slides.com