-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,64 @@ | ||
GitHubActionsの仕様を簡単に書くので英語ドキュメントしてまとめてください。GitHubのREADME.mdとして使うのでマークダウンのソースファイルとして書いてください。なお、私が書く形式に従う必要はないので、適切なドキュメントとして適切な表現になおしてください。 | ||
# Docker Image Builder | ||
|
||
このアクションが行うこと。 | ||
This GitHub Action automatically builds Docker images and pushes them to the GitHub Container Registry (GHCR) whenever a Dockerfile is committed to a repository and a branch or tag is pushed. | ||
|
||
- リポジトリ内のDockerfileを自動的にビルドしてイメージをGHCRにPUSHする。 | ||
## Usage | ||
|
||
定義されている引数 | ||
To use this action in your workflow, add the following step to your `.github/workflows/main.yml` file: | ||
|
||
token: GHCRにアクセスするためのトークン(必須) | ||
branch: 対象となるブランチ名(必須)。このブランチがPUSHされた場合にのみ動作する | ||
only_changed: trueの場合は前回のコミットにDockerfileが含まれていればビルドおよびPUSHを行う(オプショナル。default=true) | ||
with_branch: trueの場合イメージ名にブランチ名を含める(オプショナル。default=false) | ||
width_timestamp: trueの場合イメージ名にタイムスタンプを含める() | ||
```yaml | ||
name: 'Test to publish Docker image' | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: 'Test' | ||
uses: kengo-k/docker-build@v1 | ||
with: | ||
token: ${{ secrets.GHCR_TOKEN }} | ||
timezone: 'Asia/Tokyo' | ||
args: | | ||
- path: .github/workflows/Dockerfile | ||
name: helloworld | ||
on_branch_pushed: true | ||
on_branch_changed: true | ||
on_tag_pushed: true | ||
include_branch_name: true | ||
include_timestamp: true | ||
include_commit_sha: true | ||
``` | ||
### Input Arguments | ||
- `token` (required): A token with permissions to access the GitHub repository information and push images to GHCR. | ||
- `timezone` (optional): The timezone used for generating timestamps in the image tags. Default is UTC. | ||
- `args` (required): An array of objects specifying the configuration values for building Dockerfiles. Each object should contain the following properties: | ||
- `path` (required): The path to the Dockerfile. | ||
- `name` (required): The name of the built image. | ||
- `on_branch_pushed` (optional): Whether to build the image when a branch is pushed. Default is `true`. | ||
- `on_branch_changed` (optional): If `on_branch_pushed` is `true`, only build the image if the Dockerfile is included in the commit. Default is `true`. | ||
- `on_tag_pushed` (optional): Whether to build the image when a tag is pushed. Default is `true`. | ||
- `include_branch_name` (optional): Whether to include the branch name in the image tag when a branch is pushed. Default is `true`. | ||
- `include_timestamp` (optional): Whether to include a timestamp in the image tag when a branch is pushed. Default is `true`. | ||
- `include_commit_sha` (optional): Whether to include the commit ID in the image tag when a branch is pushed. Default is `true`. | ||
|
||
## How It Works | ||
|
||
When a branch or tag is pushed to the repository, this action will: | ||
|
||
1. Check if a Dockerfile is present in the repository based on the provided `path` in the `args` configuration. | ||
2. If `on_branch_pushed` is `true` and the push event is for a branch, build the Docker image. | ||
3. If `on_branch_changed` is `true`, only build the image if the Dockerfile is included in the commit. | ||
4. If `on_tag_pushed` is `true` and the push event is for a tag, build the Docker image. | ||
5. Generate an image tag based on the specified options (`include_branch_name`, `include_timestamp`, `include_commit_sha`). | ||
6. Build the Docker image using the provided Dockerfile and image name. | ||
7. Push the built image to the GitHub Container Registry (GHCR) using the generated tag. | ||
|
||
This action simplifies the process of building and pushing Docker images to GHCR, making it easier to automate your container deployment workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
name: 'Hello World' | ||
description: 'Greet someone and record the time' | ||
name: 'get' | ||
description: 'Get information for building Docker images' | ||
inputs: | ||
token: | ||
description: 'GitHub Token' | ||
required: true | ||
timezone: | ||
description: 'Timezone' | ||
description: 'Timezone for creating timestamps to include in image tag' | ||
required: true | ||
default: 'UTC' | ||
args: | ||
description: 'Who to greet' | ||
description: 'Configuration values for building images' | ||
required: true | ||
outputs: | ||
build_args: | ||
description: 'The generated docker command' | ||
description: 'Arguments to pass to the docker build command' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |