Skip to content

Commit

Permalink
Update issue_triage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayank77maruti authored Dec 19, 2024
1 parent 7471e37 commit 787da44
Showing 1 changed file with 43 additions and 45 deletions.
88 changes: 43 additions & 45 deletions .github/workflows/issue_triage.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,54 @@
name: Issue Triage and Assignment
name: Fetch Issue Number and Project Items

on:
issues:
types: [labeled, assigned]

permissions: write-all
push:
branches:
- main
workflow_dispatch:

jobs:
verify-and-move-issue:
fetch-issue-data:
runs-on: ubuntu-latest

steps:
- name: Check Project Assignments
id: check-projects
uses: actions/github-script@v6
with:
script: |
const query = `
query($owner: String!, $repo: String!, $issueNumber: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $issueNumber) {
number
projectItems(first: 100) {
nodes {
project {
title
}
}
}
- name: Checkout repository
uses: actions/checkout@v3

- name: Fetch issues from repository
id: fetch_issues
run: |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/oppia/oppia-android/issues?state=open")
issue_number=$(echo "$response" | jq '.[0].number')
echo "Issue number: $issue_number"
echo "ISSUE_NUMBER=$issue_number" >> $GITHUB_ENV
- name: Set up GraphQL query with dynamic issue number
run: |
echo "GRAPHQL_QUERY=$(cat <<EOF
{
repository(owner: \"oppia\", name: \"oppia-android\") {
issue(number: ${{ env.ISSUE_NUMBER }}) {
number
projectItems(first: 100) {
nodes {
project {
title
}
}
}
`;
const variables = {
owner: context.repo.owner,
repo: context.repo.repo,
issueNumber: context.issue.number
};
}
}
}
EOF
)" >> $GITHUB_ENV
const result = await github.graphql(query, variables);
const projects = result.repository.issue.projectItems.nodes;
- name: Run GraphQL query using GitHub API
uses: octokit/graphql-action@v3
with:
query: ${{ env.GRAPHQL_QUERY }}
github_token: ${{ secrets.GITHUB_TOKEN }}

if (projects.length !== 1) {
const message = \`This issue must belong to exactly one project. Currently assigned to ${projects.length} project(s).\`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: message
});
core.setOutput('projectValid', false);
} else {
core.setOutput('projectValid', true);
core.setOutput('projectTitle', projects[0].project.title);
}
- name: Output results
run: |
echo "Fetched issue number: ${{ env.ISSUE_NUMBER }} and project items"

0 comments on commit 787da44

Please sign in to comment.