Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR-13416 - add push trigger for e2e workflow #1100

Merged
merged 2 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
});

93 changes: 46 additions & 47 deletions .github/workflows/trigger-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -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,
}
})
Loading