From dff70396cdaa42f3e97bd9f659d8745534bf9329 Mon Sep 17 00:00:00 2001 From: David Antoon Date: Sun, 14 Jan 2024 19:44:31 +0200 Subject: [PATCH] - run pipeline on push for release/next branch - remove unused step --- .github/workflows/publish-prerelease.yml | 29 -------- .github/workflows/trigger-e2e-test.yml | 93 ++++++++++++------------ 2 files changed, 46 insertions(+), 76 deletions(-) diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index d8bf5f64d..4e9f89e04 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -138,32 +138,3 @@ jobs: state: 'pending', description: 'Dispatching E2E tests...', }); - - name: "Trigger E2E tests" - uses: actions/github-script@v5 - env: - PR_REF: '${{ steps.cpr.outputs.pull-request-head-sha }}' - PR_VERSION: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }}' - with: - github-token: ${{ secrets.E2E_WORKFLOW_TOKEN }} - script: | - const version = process.env.PR_VERSION; - const sha = process.env.PR_REF; - const repo = context.payload.repository.name - - const owner = context.payload.repository.organization - const e2eRepo = 'e2e-system-tests' - const workflow_id = 'frontegg-react-e2e-tests.yml' - const context = `${owner}/${e2eRepo}` - const dispatch_id = `${repo}/${sha}` - - const data = await github.rest.actions.createWorkflowDispatch({ - owner, - repo:e2eRepo, - workflow_id, - ref: 'main', - inputs: { - version, - dispatch_id, - } - }); - diff --git a/.github/workflows/trigger-e2e-test.yml b/.github/workflows/trigger-e2e-test.yml index 2513ad02e..c056b7bfb 100644 --- a/.github/workflows/trigger-e2e-test.yml +++ b/.github/workflows/trigger-e2e-test.yml @@ -1,51 +1,50 @@ name: Trigger E2E tests Workflow on: - workflow_dispatch: - inputs: - version: - description: 'Version' - required: true - repo: - description: 'Repository name' - required: true - sha: - description: 'Commit SHA' - required: true - + push: + branches: + - 'release/next' jobs: - trigger_e2e_tests: - name: "Trigger E2E tests Workflow" - runs-on: ubuntu-latest - steps: - - id: create_bot_token - name: Create bot token - uses: wow-actions/use-app-token@v2 - with: - app_id: ${{ secrets.GH_FRONTEGG_BOT_APP_ID }} - private_key: ${{ secrets.GH_FRONTEGG_BOT_APP_SECRET }} - - name: "Trigger E2E tests" - uses: actions/github-script@v5 - env: - version: ${{ inputs.version }} - repo: ${{ inputs.repo }} - sha: ${{ inputs.sha }} - with: - github-token: ${{ steps.create_bot_token.outputs.BOT_TOKEN }} - script: | - const {repo, sha, version} = process.env; - const owner = 'frontegg' - const e2eRepo = 'e2e-system-tests' - const workflow_id = 'frontegg-react-e2e-tests.yml' - const dispatch_id = `${repo}/${sha}` - - github.rest.actions.createWorkflowDispatch({ - owner, - repo: e2eRepo, - workflow_id, - ref: 'master', - inputs: { - version, - dispatch_id, - } - }) + trigger_e2e_tests: + name: "Trigger E2E tests Workflow" + runs-on: ubuntu-latest + steps: + - id: create_bot_token + name: Create bot token + uses: wow-actions/use-app-token@v2 + with: + app_id: ${{ secrets.GH_FRONTEGG_BOT_APP_ID }} + private_key: ${{ secrets.GH_FRONTEGG_BOT_APP_SECRET }} + - name: "get test version" + uses: actions/github-script@v6 + id: 'react_version' + with: + result-encoding: string + script: | + const {default: fs} = await import('fs'); + const {version} = JSON.parse(fs.readFileSync('./lerna.json', {encoding: "utf-8"})); + return version; + - name: "Trigger E2E tests on ${{ steps.react_version.outputs.result }}" + uses: actions/github-script@v5 + env: + version: ${{ steps.react_version.outputs.result }} + sha: ${{ github.sha }} + with: + github-token: ${{ steps.create_bot_token.outputs.BOT_TOKEN }} + script: | + const { sha, version} = process.env; + const owner = 'frontegg' + const e2eRepo = 'e2e-system-tests' + const workflow_id = 'frontegg-react-e2e-tests.yml' + const dispatch_id = `frontegg-react/${sha}` + + github.rest.actions.createWorkflowDispatch({ + owner, + repo: e2eRepo, + workflow_id, + ref: 'master', + inputs: { + version, + dispatch_id, + } + })