Create manual-test.yml #25
This file contains hidden or 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
name: Manual Test Processing | |
on: | |
issues: | |
types: [opened, edited, labeled] | |
jobs: | |
process-manual-test: | |
runs-on: ubuntu-latest | |
if: contains(toJson(github.event.issue.labels), 'manual-test') | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Parse Issue Form Data | |
id: parse | |
uses: issue-ops/[email protected] | |
with: | |
body: ${{ github.event.issue.body }} | |
issue-form-template: manual-test-report.yml | |
- name: Display Parsed Data | |
run: | | |
echo "User Name: ${{ steps.parse.outputs.json.user_name }}" | |
echo "Test ID: ${{ steps.parse.outputs.json.test_id }}" | |
echo "LabVIEW Version: ${{ steps.parse.outputs.json.labview_version }}" | |
echo "LabVIEW Bitness: ${{ steps.parse.outputs.json.labview_bitness }}" | |
echo "Operating System: ${{ steps.parse.outputs.json.os_used }}" | |
echo "Test Result: ${{ steps.parse.outputs.json.test_result }}" | |
echo "Notes: ${{ steps.parse.outputs.json.notes }}" | |
# ------------------------ | |
# Example Step: Archive Test Report Data | |
# ------------------------ | |
- name: Update JSON Archive | |
uses: actions/github-script@v6 | |
env: | |
FORM_DATA: ${{ steps.parse.outputs.json }} | |
with: | |
script: | | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
const path = "docs/test_reports.json"; | |
let existingData = []; | |
let sha; | |
try { | |
const response = await github.rest.repos.getContent({ owner, repo, path }); | |
sha = response.data.sha; | |
existingData = JSON.parse(Buffer.from(response.data.content, 'base64').toString()); | |
} catch (error) { | |
// If the file doesn't exist, we create it. | |
if (error.status !== 404) { | |
throw error; | |
} | |
} | |
const form = JSON.parse(process.env.FORM_DATA); | |
const issueNumber = context.payload.issue.number; | |
// Remove any existing record for the issue. | |
existingData = existingData.filter(record => record.issue_number !== issueNumber); | |
const newRecord = { | |
issue_number: issueNumber, | |
user_name: form.user_name, | |
test_id: form.test_id, | |
labview_version: form.labview_version, | |
labview_bitness: form.labview_bitness, | |
os_used: form.os_used, | |
test_result: form.test_result, | |
notes: form.notes || '', | |
created_at: context.payload.issue.created_at, | |
}; | |
existingData.push(newRecord); | |
// Optionally sort the records. | |
existingData.sort((a, b) => a.issue_number - b.issue_number); | |
const newContent = JSON.stringify(existingData, null, 2); | |
const encoded = Buffer.from(newContent).toString('base64'); | |
await github.rest.repos.createOrUpdateFileContents({ | |
owner, | |
repo, | |
path, | |
message: `Update test_reports.json for issue #${issueNumber}`, | |
content: encoded, | |
sha: sha || undefined, | |
}); | |
# ------------------------ | |
# Auto-Assign the Issue Creator (Production Ready) | |
# ------------------------ | |
- name: Auto-Assign Issue Creator | |
uses: kentaro-m/auto-assign | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
assignees: "author" | |