■ はじめに
https://dk521123.hatenablog.com/entry/2021/11/04/142835
https://dk521123.hatenablog.com/entry/2022/06/16/151443
の続き。 Github Actions に関する Tips を徐々にではあるが、書き溜めていく。
目次
【1】過去の履歴を見たい場合 【2】Market Placeの活用 1)Market Place の検索について 【3】README.mdにCIバッチを導入するには 【4】UUIDを扱うには 【5】イベントの判定 【6】値を受け渡す 1)Stepで値を受け渡す 2)Job間の値の受け渡しに使う
【1】過去の履歴を見たい場合
[1] Github の該当のページを開き、 [Actions]を選択 [2] 左側の「Workflows」の該当するワークフロー(今回の場合「CI」)を選択 [3] 該当の実行結果を選択 [4] 「build」を選択 => すると、YAMLファイルに記載された内容が表示されている
【2】Market Placeの活用
* Market Place によく使うものが用意されている * 以下が参考になると思う。
https://yoshikiito.net/blog/archives/python-github-actions-flake8/
1)Market Place の検索について
https://github.com/marketplace?type=actions
で、対象のツール(例えば、「flake8」と「black」)を検索して使う
flake8 の場合
* 「Flake8 action」を選択
https://github.com/marketplace/actions/flake8-action
black の場合
* 「Black Check」を選択
https://github.com/marketplace/actions/black-check
【3】README.mdにCIバッチを導入するには
* 一度は、Github Actionsを実行していること
手順
[1] Github にログインし、対象リポジトリを選択 [2] [Action]を選択 [3] 最新のGithub Actions実行結果を選択 [4] 右上にある [...]-[Create Status badge]を選択 [5] [Copy status badge Markdown]を選択 => [![...://github.com/.../badge.svg)](https://github.com/...yml]みたいなのが コピーされるので、これを README.md などに張る
【4】UUIDを扱うには
* 色々な方法で実装可能だと思うが、 以下の「uuidgen」コマンドを利用するのが一番簡単だと思う
https://stackoverflow.com/questions/63159544/how-to-create-random-uuid-in-a-github-action
サンプル
name: Test linux job on: push jobs: testJob: name: Demo for UUID runs-on: ubuntu-latest steps: - run: | UUID=$(uuidgen) echo "Result = ${UUID}"
【5】イベントの判定
* Reusable Github workflow を使うなどにどのイベントなのかを判定した * github.event_name で判定可能
https://dk521123.hatenablog.com/entry/2024/04/10/152101
# の「1)プルリクかどうかを判定するには」より抜粋 github.event_name == 'pull_request'
【6】値を受け渡す
1)Stepで値を受け渡す
* GITHUB_ENV を行う => 詳細は、以下の関連記事を参照のこと
Github Actions ~ GITHUB_ENV ~
https://dk521123.hatenablog.com/entry/2023/12/29/000840
2)Job間の値の受け渡しに使う
* GITHUB_OUTPUT を行う => 詳細は、以下の関連記事を参照のこと
Github Actions ~ GITHUB_OUTPUT ~
https://dk521123.hatenablog.com/entry/2024/01/30/002943
関連記事
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 Actions ~ GITHUB_ENV ~
https://dk521123.hatenablog.com/entry/2023/12/29/000840
Github Actions ~ GITHUB_OUTPUT ~
https://dk521123.hatenablog.com/entry/2024/01/30/002943
Github Actions ~ pull_request / pull_request_target ~
https://dk521123.hatenablog.com/entry/2024/04/10/152101
Github Actions ~ エラー処理 ~
https://dk521123.hatenablog.com/entry/2024/01/01/232057
Github Actions ~ timeout-minutes ~
https://dk521123.hatenablog.com/entry/2024/02/09/000129
Github Actions ~ Python関連 ~
https://dk521123.hatenablog.com/entry/2022/06/21/143624
Github Actions ~ Self-hosted runners / 入門編 ~
https://dk521123.hatenablog.com/entry/2023/12/18/204119
Github Actions ~ Self-hosted runners / あれこれ編 ~
https://dk521123.hatenablog.com/entry/2024/02/07/002736
Github ~ Webhook 編 ~
https://dk521123.hatenablog.com/entry/2020/01/25/224402