-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
1 parent
3fe69b0
commit 72b3aa8
Showing
2 changed files
with
72 additions
and
54 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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Create pull request to scaffold Terraform Module | ||
description: Create pull request to scaffold Terraform Module | ||
inputs: | ||
github_token: | ||
description: 'GitHub Access Token' | ||
required: true | ||
|
||
module_path: | ||
description: 'Module path' | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- run: | | ||
echo "::error ::github_token is required" | ||
exit 1 | ||
shell: bash | ||
if: inputs.github_token == '' | ||
- run: | | ||
echo "::error ::module_path is required" | ||
exit 1 | ||
shell: bash | ||
if: inputs.module_path == '' | ||
- uses: suzuki-shunsuke/tfaction/get-global-config@main | ||
id: global-config | ||
|
||
- run: | | ||
echo "::set-output name=branch::scaffold-module-${MODULE_PATH/\//_}-$(date +%Y%m%dT%H%M%S)" | ||
id: branch | ||
shell: bash | ||
env: | ||
MODULE_PATH: ${{inputs.module_path}} | ||
- run: git add "$MODULE_PATH" | ||
shell: bash | ||
env: | ||
MODULE_PATH: ${{inputs.module_path}} | ||
|
||
- run: | | ||
git diff --cached --name-only | | ||
xargs ghcp commit -r "$GITHUB_REPOSITORY" \ | ||
-b "${{steps.branch.outputs.branch}}" \ | ||
-m "chore($MODULE_PATH): scaffold a Terraform Module" | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
MODULE_PATH: ${{inputs.module_path}} | ||
- run: | | ||
opts=(-R "$GITHUB_REPOSITORY" -H "${{steps.branch.outputs.branch}}" -t "\"Scaffold a Terraform Module (${MODULE_PATH})\"" -b "\"This pull request was created by [GitHub Actions](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)\"") | ||
if [ "${{steps.global-config.outputs.draft_pr}}" = "true" ]; then | ||
opts+=( -d ) | ||
fi | ||
echo "::notice title=Create a scaffold pull request::$ gh pr create ${opts[@]}" | ||
if: "fromJSON(steps.global-config.outputs.skip_create_pr)" | ||
shell: bash | ||
env: | ||
MODULE_PATH: ${{inputs.module_path}} | ||
- run: | | ||
opts=(-H "${{steps.branch.outputs.branch}}" -a "$GITHUB_ACTOR" -t "Scaffold a Terraform Module (${MODULE_PATH})" -b "@$GITHUB_ACTOR This pull request was created by [GitHub Actions workflow_dispatch event](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)") | ||
if [ "${{steps.global-config.outputs.draft_pr}}" = "true" ]; then | ||
opts+=( -d ) | ||
fi | ||
gh pr create "${opts[@]}" | ||
shell: bash | ||
if: "!fromJSON(steps.global-config.outputs.skip_create_pr)" | ||
env: | ||
GITHUB_TOKEN: ${{ inputs.github_token }} | ||
MODULE_PATH: ${{inputs.module_path}} |
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