Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .textlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"rules": {
"preset-ja-technical-writing": {
"sentence-length": {
"max": 150
},
"no-exclamation-question-mark": false,
"ja-no-weak-phrase": false
},
"preset-jtf-style": true
}
Comment on lines +1 to +11
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rules だけだと、MDX(import/JSX を含む)をパースできる plugin が有効にならず、src/content/**/*.mdx の lint 実行時に解析エラーになる可能性があります。MD/MDX を確実に lint するために、対応する textlint plugin(markdown/mdx など)を明示的に設定するか、MDX を対象外にする設定(ignorePatterns 等)を追加してください。

Copilot uses AI. Check for mistakes.
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"test:e2e:report": "playwright show-report",
"deploy": "pnpm build && wrangler deploy"
"deploy": "pnpm build && wrangler deploy",
"textlint": "textlint 'src/content/**/*.{md,mdx}'",
"textlint:fix": "textlint --fix 'src/content/**/*.{md,mdx}'"
Comment on lines +21 to +22
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textlint の対象に .mdx を含めていますが、現在のコンテンツは冒頭の import ...<OgpCard /> など MDX 構文を使っています。追加されている依存関係/設定だと Markdown パーサ(@textlint/textlint-plugin-markdown)しか入っておらず、pnpm textlint が MDX の解析エラーで落ちる可能性が高いです。MDX 対応の textlint プラグインを追加して .textlintrc の plugins を設定するか、少なくともスクリプトの対象を .md のみに絞ってください。

Suggested change
"textlint": "textlint 'src/content/**/*.{md,mdx}'",
"textlint:fix": "textlint --fix 'src/content/**/*.{md,mdx}'"
"textlint": "textlint 'src/content/**/*.md'",
"textlint:fix": "textlint --fix 'src/content/**/*.md'"

Copilot uses AI. Check for mistakes.
},
"dependencies": {
"@astrojs/mdx": "^4.3.13",
Expand Down Expand Up @@ -46,6 +48,9 @@
"@vitest/ui": "^4.0.18",
"happy-dom": "^20.6.1",
"pagefind": "^1.4.0",
"textlint": "^15.5.1",
"textlint-rule-preset-ja-technical-writing": "^12.0.2",
"textlint-rule-preset-jtf-style": "^3.0.3",
"vitest": "^4.0.18",
"wrangler": "^4.65.0"
}
Expand Down
3,623 changes: 3,599 additions & 24 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions src/content/blog/first-post.md

This file was deleted.

176 changes: 176 additions & 0 deletions src/content/blog/github-actions-guide.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
---
title: "GitHub Actions の Composite Action を作る"
date: 2026-02-17
excerpt: "再利用可能な GitHub Actions を composite action で作る方法を、実際の CI/CD パイプライン構築を例に解説します。"
tags: ["GitHub Actions", "CI/CD"]
---

import OgpCard from "../../components/blog/OgpCard.astro";

GitHub Actions でワークフローを共通化したいとき、**composite action** が便利です。この記事では、composite action の作り方を実際のプロジェクト(dbt の CI/CD パイプライン)を例に解説します。

## Composite Action とは

Composite action は、複数のステップをひとつのアクションにまとめて再利用可能にする仕組みです。Docker コンテナや JavaScript を使わず、**シェルコマンドと既存のアクションの組み合わせ**だけで作れるのが特徴です。

通常のワークフローと比べたメリット:

- **再利用**: 複数のリポジトリから `uses:` で呼び出せる
- **バージョン管理**: タグ(`@v1`)で安定版を提供できる
- **カプセル化**: 入力(`inputs`)と出力(`outputs`)のインターフェースが明確

## ディレクトリ構成

composite action に必要なのは `action.yml` だけです。

```
my-action/
├── action.yml # アクション定義(必須)
├── scripts/ # 補助スクリプト(任意)
│ └── setup.sh
└── README.md
```

## action.yml の基本構造

```yaml
name: "My Composite Action"
description: "何をするアクションか"

inputs:
type:
description: "ジョブタイプ(ci, merge, deploy)"
required: true
adapter:
description: "使用するアダプター"
required: true
default: "snowflake"

runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install dependencies
shell: bash
run: pip install dbt-${{ inputs.adapter }}

- name: Run dbt
shell: bash
run: dbt build
```

ポイント:

- `runs.using` は `"composite"` を指定
- 各ステップに `shell` を明示する(省略不可)
- `${{ inputs.xxx }}` で入力値を参照

## inputs の設計

inputs はアクションの API です。必要十分な粒度で設計します。

```yaml
inputs:
type:
description: "ジョブタイプ"
required: true
command:
description: "実行する dbt コマンド"
required: true
deferral:
description: "差分ビルドの基準ブランチ"
required: false
default: ""
post-pr-comment:
description: "PR にコメントを投稿するか"
required: false
default: "false"
```

**設計のコツ:**
- `required: true` は本当に必須なものだけに
- デフォルト値で「よくある使い方」をゼロ設定にする
- boolean 系は文字列 `"true"` / `"false"` で受け取る

## シェルオプションの使い分け

composite action のステップでは、`shell` の設定が重要です。

```yaml
# CI: 全コマンドを実行してから結果を集約
- name: Run CI
shell: bash
run: |
set +e
dbt build --select state:modified+
result=$?
dbt test
test_result=$?
exit $((result + test_result))

# Deploy: 失敗したら即停止
- name: Run Deploy
shell: bash
run: |
set -e
dbt run
dbt test
```

`set +e` で全ステップを実行して結果を集約するパターンは、CI でテスト結果を一覧で見たいときに有効です。

## 呼び出し側のワークフロー

作成したアクションは `uses:` で呼び出します。

```yaml
name: dbt CI
on:
pull_request:

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ta93abe/dbt-jobs@v1
with:
type: ci
adapter: snowflake
command: dbt build --select state:modified+
deferral: main
post-pr-comment: true

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

記事内で「boolean 系は文字列 "true" / "false" で受け取る」(97行目)と説明されていますが、ここのサンプルコードでは post-pr-comment: true とブーリアン値が使われています。

記事の内容とサンプルコードの整合性を取るため、ここも文字列の "true" に修正するのが望ましいです。

          post-pr-comment: "true"

```

## バージョニング

リリース時にタグを打つことで、利用者はバージョンを固定できます。

```bash
git tag -a v1.0.0 -m "v1.0.0"
git push origin v1.0.0

# メジャーバージョンタグも更新
git tag -f v1
git push -f origin v1
```

`@v1` のようなメジャーバージョンタグを提供すると、利用者はパッチ更新を自動的に受け取れます。

## 実例

この記事の内容を実際に適用したプロジェクトがこちらです。

<OgpCard url="https://github.com/ta93abe/dbt-jobs" />

## まとめ

- Composite action は `action.yml` ひとつで作れる
- `inputs` で明確な API を設計する
- シェルオプション(`set -e` / `set +e`)を用途に応じて使い分ける
- メジャーバージョンタグで安定した利用体験を提供する
96 changes: 0 additions & 96 deletions src/content/blog/mdx-demo.mdx

This file was deleted.

Loading