From 30611810c7d40b56b6ee7eda180ef62b7e96cc3a Mon Sep 17 00:00:00 2001 From: Manabu McCloskey Date: Tue, 26 Nov 2024 15:35:35 -0800 Subject: [PATCH 1/2] allow /e2e in PRs to run e2e workflow Signed-off-by: Manabu McCloskey --- .github/workflows/e2e.yaml | 2 ++ .github/workflows/slash-commands.yaml | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .github/workflows/slash-commands.yaml diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2054f1b5..f1479649 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -8,6 +8,8 @@ on: - '**.go' - 'go.sum' - 'go.mod' + repository_dispatch: + types: [e2e-command] jobs: e2e: runs-on: ubuntu-22.04 diff --git a/.github/workflows/slash-commands.yaml b/.github/workflows/slash-commands.yaml new file mode 100644 index 00000000..d3213bba --- /dev/null +++ b/.github/workflows/slash-commands.yaml @@ -0,0 +1,24 @@ +name: slash-commands + +on: + issue_comment: + types: [created] + +jobs: + slash_command_dispatch: + runs-on: ubuntu-22.04 + steps: + - name: Generate a token + id: generate-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ vars.CNOE_GH_WORKFLOW_TOKEN_APP_ID }} + private-key: ${{ secrets.CNOE_GH_WORKFLOW_TOKEN_PRIVATE_KEY }} + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@v4 + with: + token: ${{ steps.generate-token.outputs.token }} + commands: | + e2e + permission: write + issue-type: pull-request From 22adab94bc0391353dded5dc8c7ad0816b5ee7c6 Mon Sep 17 00:00:00 2001 From: Manabu McCloskey Date: Wed, 27 Nov 2024 18:20:05 +0000 Subject: [PATCH 2/2] update e2e workflow to be more specific Signed-off-by: Manabu McCloskey --- .github/workflows/e2e.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index f1479649..2dda98c6 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -10,11 +10,32 @@ on: - 'go.mod' repository_dispatch: types: [e2e-command] + jobs: e2e: runs-on: ubuntu-22.04 + if: ${{ github.event.ref != '' }} + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + with: + go-version: '1.22' + - name: Run tests + run: | + make e2e + # invoked by slash command workflow + e2e-slash-command: + runs-on: ubuntu-22.04 + if: ${{ github.event.action == 'e2e-command' }} steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} + ref: ${{ github.event.client_payload.pull_request.head.ref }} + fetch-depth: 0 - name: Setup Go uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: @@ -22,3 +43,4 @@ jobs: - name: Run tests run: | make e2e +