Skip to content

Commit

Permalink
split e2e trigger workflow into two steps
Browse files Browse the repository at this point in the history
  • Loading branch information
frontegg-david committed Nov 20, 2023
1 parent 870a305 commit 17f0cbe
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 29 deletions.
63 changes: 43 additions & 20 deletions .github/workflows/publish-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,37 +103,60 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

- name: Trigger E2E test workflow
- name: Notify Slack on alpha version deployment
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: frontegg-alpha-versions
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://avatars.githubusercontent.com/u/67857107?s=40&v=4
SLACK_MESSAGE: '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }} has been released :rocket:'
SLACK_TITLE: 'A new @frontegg/react alpha version!'
SLACK_USERNAME: ${{ github.actor }}
SLACK_WEBHOOK: ${{ secrets.ROTEM_SLACK_WEBHOOK }}
MSG_MINIMAL: true

- name: Prepare E2E test workflow
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.GH_REPOSITORY_ADMIN_TOKEN }}
script: |
const sha = process.env.PR_REF;
const repo = context.payload.repository.name
const owner = context.payload.repository.organization
const res = await github.rest.repos.createCommitStatus({
context, owner, repo, sha,
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: context.payload.repository.organization,
repo: context.payload.repository.name,
workflow_id: 'trigger-e2e-test.yml',
ref: process.env.PR_REF,
owner,
repo:e2eRepo,
workflow_id,
ref: 'main',
inputs: {
version: process.env.PR_VERSION,
repo,
sha
version,
dispatch_id,
}
});
- name : Notify Slack on alpha version deployment
uses : rtCamp/action-slack-notify@v2
env :
SLACK_CHANNEL : frontegg-alpha-versions
SLACK_COLOR : ${{ job.status }}
SLACK_ICON : https://avatars.githubusercontent.com/u/67857107?s=40&v=4
SLACK_MESSAGE : '${{ steps.publish_pre_release_version.outputs.LIB_VERSION }}-alpha.${{ github.run_id }} has been released :rocket:'
SLACK_TITLE : 'A new @frontegg/react alpha version!'
SLACK_USERNAME : ${{ github.actor }}
SLACK_WEBHOOK : ${{ secrets.ROTEM_SLACK_WEBHOOK }}
MSG_MINIMAL : true
16 changes: 7 additions & 9 deletions .github/workflows/trigger-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ on:
version:
description: 'Version'
required: true
dispatch_id:
description: 'Dispatch Id (repo/sha)'
repo:
description: 'Repository name'
required: true
sha:
description: 'Commit SHA'
required: true

jobs:
Expand All @@ -19,7 +22,8 @@ jobs:
uses: actions/github-script@v5
env:
version: ${{ inputs.version }}
dispatch_id: ${{ inputs.dispatch_id }}
repo: ${{ inputs.repo }}
sha: ${{ inputs.sha }}
with:
github-token: ${{ secrets.GH_REPOSITORY_ADMIN_TOKEN }}
script: |
Expand All @@ -30,12 +34,6 @@ jobs:
const context = `${owner}/${e2eRepo}`
const dispatch_id = `${repo}/${sha}`
const res = await github.rest.repos.createCommitStatus({
context, owner, repo, sha,
state: 'pending',
description: 'Dispatching E2E tests...',
});
const data = await github.rest.actions.createWorkflowDispatch({
owner,
repo:e2eRepo,
Expand Down

0 comments on commit 17f0cbe

Please sign in to comment.