-
Notifications
You must be signed in to change notification settings - Fork 334
57 lines (48 loc) · 2.45 KB
/
automation-candidate.yaml
File metadata and controls
57 lines (48 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# create an automation task in qa-tasks repo of an issue when label "candidate-automation" is added
name: Create issue for QA automation
run-name: "Create issue for QA automation ${{ github.event.issue.number }}: ${{ github.event.issue.title }}"
on:
issues:
types:
- labeled
jobs:
create-qa-automation-task:
permissions:
contents: read
issues: write
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'issues' && github.event.label.name == 'candidate-automation'
steps:
- name: Read QA secrets
uses: rancher-eio/read-vault-secrets@7282bf97898cd1c16c89f837e0bb442e6d384c89 # v3
with:
secrets: |
github/token/rancher--qa-tasks--issues--write token | QA_GH_TOKEN
- name: Create QA automation issue
env:
GH_TOKEN: ${{ env.QA_GH_TOKEN }}
ORIGINAL_ISSUE_NUMBER: ${{ github.event.issue.number }}
ORIGINAL_ISSUE_URL: ${{ github.event.issue.html_url }}
run: |
declare -a additional_cmd
additional_cmd+=("--label" "area/automation-test-ui")
BODY=$(mktemp)
ORIGINAL_ISSUE=$(gh issue view -R ${GITHUB_REPOSITORY} ${ORIGINAL_ISSUE_NUMBER} --json title,projectItems)
ORIGINAL_TITLE=$(echo "${ORIGINAL_ISSUE}" | jq -r .title)
ORIGINAL_PROJECTS=$(echo "${ORIGINAL_ISSUE}" | jq -r '.projectItems[].title' 2>/dev/null || echo "")
if [ -n "$ORIGINAL_PROJECTS" ]; then
while IFS= read -r project; do
if [ -n "$project" ]; then
additional_cmd+=("--project" "$project")
fi
done <<< "$ORIGINAL_PROJECTS"
fi
echo -e "This is an issue that tracks QA automation testing for issue ${ORIGINAL_ISSUE_URL}, automatically created via [GitHub Actions workflow]($GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) initiated by @${GITHUB_ACTOR}\n" > $BODY
if NEW_ISSUE=$(gh issue create -R "rancher/qa-tasks" --title "[UI Automation]: ${ORIGINAL_TITLE}" --body-file "${BODY}" "${additional_cmd[@]}"); then
echo "QA task issue created: ${NEW_ISSUE}" >> $GITHUB_STEP_SUMMARY
else
echo "Failed to create issue"
GH_TOKEN=${{ secrets.GITHUB_TOKEN }} gh issue comment ${ORIGINAL_ISSUE_URL} --body "No QA automation issue was created. Failed to create issue in rancher/qa-tasks."
exit 1
fi