Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions .devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "2.5.0",
"resolved": "ghcr.io/devcontainers/features/dotnet@sha256:0fc16547ed4db6d7ff2a9f5981d2b93eb314e568affb9958029ad794f1f9a093",
"integrity": "sha256:0fc16547ed4db6d7ff2a9f5981d2b93eb314e568affb9958029ad794f1f9a093"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "1.3.4",
"resolved": "ghcr.io/devcontainers/features/go@sha256:d85e921f91b41340055bb12b325d9d551170ed04b3b832e33530bf42f167c032",
"integrity": "sha256:d85e921f91b41340055bb12b325d9d551170ed04b3b832e33530bf42f167c032"
},
"ghcr.io/devcontainers/features/node:2": {
"version": "2.1.0",
"resolved": "ghcr.io/devcontainers/features/node@sha256:586c9a6f7dd40bd3ba2cd41e7f2f88dcc31fbe5d1442afcbf07ffbc66b686857",
"integrity": "sha256:586c9a6f7dd40bd3ba2cd41e7f2f88dcc31fbe5d1442afcbf07ffbc66b686857"
}
}
}
38 changes: 38 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "Ubuntu",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/base:resolute",
"features": {
"ghcr.io/devcontainers/features/dotnet:2": {
"tabCompletions": true,
"version": "latest"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/node:2": {
"nodeGypDependencies": true,
"version": "lts",
"npmVersion": "lts",
"pnpmVersion": "latest",
"nvmVersion": "latest"
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
24 changes: 14 additions & 10 deletions .github/workflows/articles-changed-detection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@
name: Articles - Changed detection sample

on:
# push:
# branches: [ "main" ]
# paths:
# - "src/**"
pull_request:
paths:
- "articles/detections/**"
# Since variables cannot be used in `on.paths`, this part must be hardcoded.
- "articles/changed-detenctions/**"
- ".github/workflows/articles-changed-detection.yaml"
workflow_dispatch:

permissions: {}

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
TARGET_BASE_DIR: "articles/changed-detenctions"

jobs:
detect-changes:
runs-on: ubuntu-latest
Expand All @@ -42,15 +46,15 @@ jobs:
matrix: true
dir_names: true
dir_names_max_depth: 3 # path/to/xxx
files: articles/detections/**
files: ${{ env.TARGET_BASE_DIR }}/**

# Finalize the array and pass it to the output
- name: Set matrix output
id: set-matrix
run: |
# For manual execution (workflow_dispatch), target all projects under path/to/
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
PROJECTS=$(ls -d articles/detections/*/ | cut -d'/' -f3 | jq -R -s -c 'split("\n") | map(select(length > 0))')
PROJECTS=$(ls -d $TARGET_BASE_DIR/*/ | cut -d'/' -f3 | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "projects=$PROJECTS" >> $GITHUB_OUTPUT
else
# json array returned from the plugin (e.g. ["path/to/AAA", "path/to/BBB"])
Expand Down Expand Up @@ -92,7 +96,7 @@ jobs:
- name: Find Target and Define Assets Path
run: |
# 1. First, search for the target
FIND_PATH="articles/detections/${{ matrix.project }}"
FIND_PATH="$TARGET_BASE_DIR/${{ matrix.project }}"
TARGET=$(find "$FIND_PATH" -maxdepth 2 \( -name "*.slnx" -o -name "*.sln" -o -name "*.md" \) | head -n 1)

if [ -z "$TARGET" ]; then
Expand Down Expand Up @@ -120,7 +124,7 @@ jobs:

- name: Run Test Assets Scripts (If exists)
run: |
SCRIPT_PATH="articles/detections/${{ matrix.project }}/scripts/generate-test-assets.sh"
SCRIPT_PATH="$TARGET_BASE_DIR/${{ matrix.project }}/scripts/generate-test-assets.sh"
if [ -f "$SCRIPT_PATH" ]; then
echo "Found asset generation script. Running..."
chmod +x "$SCRIPT_PATH"
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions.
---
name: CI
name: Blank

# Controls when the workflow will run
on:
Expand All @@ -9,12 +9,22 @@ on:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Disable all permissions at workflow level
permissions: {}

# Picking up Bash pipe errors in default shell
defaults:
run:
shell: bash

#Auto-cancel old workflows with Concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
Expand All @@ -27,7 +37,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- uses: actions/checkout@v7

# Runs a single command using the runners shell
- name: Run a one-line script
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/chapter-1-go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Chapter 1 Hello World、ワークフローの定義ファイルの書き方.
---
name: Chapter 1 - Hello World (Go Test)

on:
# Events
# - https://docs.github.com/ja/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#issue_comment

# コミットのプッシュでワークフローをトリガーする設定
push:
branches:
- main
paths:
- "./chapters/go/go.mod"
- "./chapters/go/go.sum"
- "./chapters/go/*.go"
- ".github/workflows/chapter-1-go.yaml"

# issusのコメントでワークフローをトリガーする設定
issue_comment:
types: [created, deleted]

# 指定した時間にワークフローをトリガーする設定
# schedule:
# - cron: "0 9 1 * *" # At 09:00 on day-of-month 1.

# 手動でワークフローをトリガーする設定
workflow_dispatch:

permissions: {}
defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# job は同じランナーで実行されるステップの集合体です。
jobs:
build:
# ランナーの指定
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
defaults:
run:
working-directory: ./chapters/go/

# steps は job の中で実行されるタスクの集合体です。
steps:
# 複雑な処理や頻繁に使用する処理は、アクションを定義して使用することができます。
- uses: actions/checkout@v7

- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.26.5"
cache: false

- name: Build
run: go build -v .
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
# Chapter 2 プルリクエスト駆動でCIを実現する.
---
name: Chapter 2 - CI
name: Chapter 2 (1) - CI

on:
pull_request:
branches:
- main
paths:
- "go.mod"
- "go.sum"
- "**.go"
- "./chapters/go/go.mod"
- "./chapters/go/go.sum"
- "./chapters/go/*.go"
- ".github/workflows/chapter-2-1-ci.yaml"
workflow_dispatch:

permissions: {}
defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
name: ci
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
working-directory: ./chapters/go/

steps:
- name: チェックアウトする
uses: actions/checkout@v4
uses: actions/checkout@v7
- name: Go の環境をセットアップする
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: "1.23.1"
go-version: "1.26.5"

- name: フォーマットを実行する
# フォーマット違反時にステップを失敗させる
run: test -z "$(gofmt -l .)"
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/cd.yaml → .github/workflows/chapter-2-2-cd.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# Chapter 2 マージ駆動でCDを実現する.
---
name: Chapter 2 - CD
name: Chapter 2 (2) - CD

on:
push:
branches:
- main
paths:
- 'go.mod'
- 'go.sum'
- '**.go'
- "./chapters/go/go.mod"
- "./chapters/go/go.sum"
- "./chapters/go/*.go"
workflow_dispatch:

permissions: {}
defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
cd:
Expand All @@ -25,19 +29,19 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
# - name: Container registory に認証する
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- uses: actions/checkout@v7
- name: Container registory に認証する
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Container registory に認証する
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Docker ビルドする
# run: docker build -t ghcr.io/${{ github.repository }}:latest .
# - name: Docker イメージをプッシュする
# run: docker push ghcr.io/${{ github.repository }}:latest
- name: Docker ビルドする
run: docker build -t ghcr.io/${{ github.repository }}:latest .
- name: Docker イメージをプッシュする
run: docker push ghcr.io/${{ github.repository }}:latest
- name: Docker をビルドおよびプッシュする
uses: docker/build-push-action@v5
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chapter 3 ワークフロー内で利用可能な値(コンテキスト).
---
name: Chapter 3 - actions/context
name: Chapter 3 (1) - actions/context

on:
pull_request:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"

- uses: actions/checkout@v4
- uses: actions/checkout@v7
id: checkout
- name: actions/checkout のステータスを表示
run: echo "${{ steps.checkout.conclusion }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chapter 3 ジョブの成果物の保存、次のジョブへの受け渡し.
---
name: Chapter 3 - actions/artifacts
name: Chapter 3 (2) - actions/artifacts

on:
pull_request:
Expand All @@ -19,7 +19,7 @@ jobs:
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: ビルド(ダミー)
run: |
date > dummy.txt
Expand All @@ -37,7 +37,7 @@ jobs:
permissions:
contents: write # gh release upload に必要
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- name: 成果物のダウンロード
uses: actions/download-artifact@v4
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Chapter 3 ジョブとステップの実行制御.
---
name: Chapter 3 - Control Flow
name: Chapter 3 (3) - Control Flow

on:
# pull_request:
Expand Down
Loading
Loading