6
2

More than 1 year has passed since last update.

【GitHub】GitHub Actionsで独自のActionを定義する

Posted at

はじめに

最近、GitHub ActionsのWorkflowを構築するお仕事をしていたので、そこで発見したTipsについて書きます!
同一リポジトリ内で同じActionを呼びたい』時に便利です!

Node.jsのcomposite action

composite action ・・・ ユーザーが独自に定義したAction

.github/workflow/node/action.yml
name: my-actions

runs:
  using: 'composite'
  steps:
    - name: set up Node.js
      uses: actions/setup-node@v2
      with:
        node-version: '14'
        cache: 'npm' # or 'yarn'
        cache-dependency-path: app/node/package-lock.json

!!!注意!!!

The metadata filename must be either action.yml or action.yaml.

ファイル名はaction.ymlまたはaction.yamlでないといけないです!

runs.using
Required You must set this value to 'composite'.

独自でAcitonsを定義す時には、usign: compositeを付与しないといけないです!

呼び出し元のActions

.github/workflows/test.yml
name: Test

on:
  push:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: ./.github/actions/node # 👈

ディレクトリを指定すると、呼び出すことができます🙌

備考

もうちょっと踏み込んだことがわかったら、追記します🙇‍♂️

公式

composite action
Metadata syntax for GitHub Actions

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2