diff --git a/create-scaffold-monorepo-pr/action.yaml b/create-scaffold-monorepo-pr/action.yaml new file mode 100644 index 000000000..1604de226 --- /dev/null +++ b/create-scaffold-monorepo-pr/action.yaml @@ -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}} diff --git a/scaffold-module/action.yaml b/scaffold-module/action.yaml index bd4d9d36d..ee6cb8393 100644 --- a/scaffold-module/action.yaml +++ b/scaffold-module/action.yaml @@ -1,10 +1,6 @@ name: Scaffold Terraform Module description: Scaffold Terraform Module inputs: - github_token: - description: 'GitHub Access Token' - required: true - module_path: description: 'Module path' required: true @@ -12,11 +8,6 @@ inputs: 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 @@ -84,48 +75,3 @@ runs: - run: terraform-docs . > README.md shell: bash working-directory: ${{inputs.module_path}} - - - 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}}