diff --git a/modules/github/Makefile.init b/modules/github/Makefile.init index b1759956..3857ea64 100644 --- a/modules/github/Makefile.init +++ b/modules/github/Makefile.init @@ -7,6 +7,12 @@ GITHUB_TEMPLATES = \ .github/ISSUE_TEMPLATE/bug_report.md \ .github/ISSUE_TEMPLATE/question.md + +ifneq ($(wildcard *.tf),) +# Install test workflow for terraform projects +GITHUB_TEMPLATES += .github/workflows/chatops.yml +endif + $(GITHUB_TEMPLATES): $(addprefix $(BUILD_HARNESS_PATH)/templates/, $(GITHUB_TEMPLATES)) mkdir -p $(dir $@) cp $(BUILD_HARNESS_PATH)/templates/$@ $@ diff --git a/templates/.github/workflows/chatops.yml b/templates/.github/workflows/chatops.yml new file mode 100644 index 00000000..a6bb11b4 --- /dev/null +++ b/templates/.github/workflows/chatops.yml @@ -0,0 +1,37 @@ +name: chatops +on: + issue_comment: + types: [created] + +jobs: + default: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Handle common commands" + uses: cloudposse/actions/github/slash-command-dispatch@0.15.0 + with: + token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} + reaction-token: ${{ secrets.GITHUB_TOKEN }} + repository: cloudposse/actions + commands: rebuild-readme, terraform-fmt + permission: none + issue-type: pull-request + + test: + runs-on: ubuntu-latest + steps: + - name: "Checkout commit" + uses: actions/checkout@v2 + - name: "Run tests" + uses: cloudposse/actions/github/slash-command-dispatch@0.15.0 + with: + token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} + reaction-token: ${{ secrets.GITHUB_TOKEN }} + repository: cloudposse/actions + commands: test + permission: none + issue-type: pull-request + reactions: false + + diff --git a/templates/.github/workflows/slash-command-dispatch.yml b/templates/.github/workflows/slash-command-dispatch.yml deleted file mode 100644 index 3e3c1387..00000000 --- a/templates/.github/workflows/slash-command-dispatch.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Slash Command Dispatch -on: - issue_comment: - types: [created] - -jobs: - slashCommandDispatch: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Slash Command Dispatch - uses: cloudposse/actions/github/slash-command-dispatch@0.12.0 - with: - token: ${{ secrets.GITHUB_BOT_TOKEN }} - reaction-token: ${{ secrets.GITHUB_TOKEN }} - repository: cloudposse/actions - commands: rebuild-readme, terraform-fmt - permission: none - issue-type: pull-request