-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CI): Automatically create live test if checkbox in e2e test is c…
…hecked (#261)
- Loading branch information
1 parent
162092a
commit 2277c3a
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Create Issue on Checkbox Checked | ||
|
||
on: | ||
issues: | ||
types: | ||
- opened | ||
- edited | ||
jobs: | ||
create_e2e_live_issue: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check if a checkbox was checked | ||
id: check_checkbox | ||
run: | | ||
checkbox=$(echo "${{ github.event.issue.body }}" | awk '/### Live Test/{getline; getline; print}' | tr -d '\n' | grep -q '^\- \[X\] Yes$' && echo "y" || echo "n") | ||
echo $checkbox | ||
if [[ "$checkbox" = "y" ]]; then | ||
echo "::set-output name=checked::true" | ||
else | ||
echo "::set-output name=checked::false" | ||
fi | ||
- name: Create a new issue | ||
if: steps.check_checkbox.outputs.checked == 'true' | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issueTitle = '[LIVE]${{ github.event.issue.title }}'; | ||
const issueBody = `Issue live-test relate to [this issue](${context.payload.issue.html_url}).`; | ||
const newIssue = await github.rest.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: issueTitle, | ||
body: issueBody, | ||
}); | ||
core.setOutput('issue_number', newIssue.data.number); |