【Github】Github Custom Action ~ Custom Actionを使ってもらうには ~

■ はじめに

https://dk521123.hatenablog.com/entry/2024/06/27/220219
https://dk521123.hatenablog.com/entry/2024/06/28/030619
https://dk521123.hatenablog.com/entry/2024/06/29/021837

で Github Custom Action を一通り使うことができた。

 今回は、それらを同じ組織内で使ってもううための Tips を纏める。

目次

【1】リリース管理
 1)タグを使用したリリース管理
 2)ブランチを使用したリリース管理
 3)コミットの SHA を使用したリリース管理
【2】アクションを組織で共有するには
 1)Github リポジトリ作成
 2)Github リポジトリの GitHub Actions の設定変更

【1】リリース管理

* リリース管理には、以下の3通り。

1)タグを使用したリリース管理 << ★推奨★
2)ブランチを使用したリリース管理
3)コミットの SHA を使用したリリース管理

https://docs.github.com/ja/actions/creating-actions/about-custom-actions#good-practices-for-release-management

1)タグを使用したリリース管理

* アクションのリリース管理に「タグ」を使用する方法

https://docs.github.com/ja/actions/creating-actions/about-custom-actions#using-tags-for-release-management

steps:
    - uses: actions/javascript-action@v1
    # - uses: actions/javascript-action@v1.0.1

利点

* 利用者はメジャーバージョンとマイナーバージョンを簡単に区別できる

2)ブランチを使用したリリース管理

* アクションのリリース管理に「ブランチ」を使用する方法

https://docs.github.com/ja/actions/creating-actions/about-custom-actions#using-branches-for-release-management

3)コミットの SHA を使用したリリース管理

* アクションのリリース管理に「コミットのハッシュ値」を使用する方法

https://docs.github.com/ja/actions/creating-actions/about-custom-actions#using-a-commits-sha-for-release-management

* 以下の関連記事で使用している方法。

https://dk521123.hatenablog.com/entry/2024/06/29/021837
ハッシュタグ取得

# 完全なハッシュ %H / 短縮版のハッシュ %h
# --no-patch: コミットの diff 出力を行わないようにする
$ git show --format='%H' --no-patch
3b3f59d...

ハッシュタグを記載

      - id: foo
        # ★ここを修正する(@以降は、ハッシュタグを記載)
        uses: your-github-user-name/hello-world-composite-action@3b3f59d...
        with:
          who-to-greet: 'Mona the Octocat'

【2】アクションを組織で共有するには

* 以下の公式ドキュメントを参照

https://docs.github.com/ja/actions/creating-actions/sharing-actions-and-workflows-with-your-organization#sharing-actions-and-workflows-with-your-organization

1)Github リポジトリ作成

* アクションをプライベートのリポジトリに格納

2)Github リポジトリGitHub Actions の設定変更

* 以下の公式ドキュメントを参照

https://docs.github.com/ja/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#allowing-access-to-components-in-a-private-repository

[1] GitHub で、プライベート リポジトリのメイン ページに移動
[2] リポジトリ名の下にある  [Settings] をクリック
[3] 左のサイドバーで  [Actions] をクリックして、 [General] をクリック
[4] [Access] で、
 [Accessible from repositories owned by the user '<YourAccount>']を選択
[5] [Save] をクリック

参考文献

https://docs.github.com/ja/actions/creating-actions/releasing-and-maintaining-actions
https://docs.github.com/ja/actions/creating-actions/sharing-actions-and-workflows-from-your-private-repository
https://docs.github.com/ja/actions/creating-actions/sharing-actions-and-workflows-with-your-organization

関連記事

Github ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2019/07/18/234652
Github Actions ~ 基礎知識編 ~
https://dk521123.hatenablog.com/entry/2021/11/04/142835
Github Actions ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2022/06/16/151443
Github Actions ~ 基本編 ~
https://dk521123.hatenablog.com/entry/2023/12/22/195715
Github Custom Action ~ 入門編 ~
https://dk521123.hatenablog.com/entry/2024/06/27/220219
Github Custom Action ~ Docker コンテナー ~
https://dk521123.hatenablog.com/entry/2024/06/28/030619
Github Custom Action ~ 複合アクション ~
https://dk521123.hatenablog.com/entry/2024/06/29/021837
Node.js ~ 環境構築編 ~
https://dk521123.hatenablog.com/entry/2021/11/06/000000
Git ~ 基本編 / 基本コマンド ~
https://dk521123.hatenablog.com/entry/2020/10/02/000000