From 787da44d8c6864fea51aa6a3eb27afd0f747a3e4 Mon Sep 17 00:00:00 2001 From: Mayank Mohapatra <125661248+Mayank77maruti@users.noreply.github.com> Date: Thu, 19 Dec 2024 13:47:38 +0530 Subject: [PATCH] Update issue_triage.yml --- .github/workflows/issue_triage.yml | 88 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/.github/workflows/issue_triage.yml b/.github/workflows/issue_triage.yml index a275a100b1b..6df039d5b3b 100644 --- a/.github/workflows/issue_triage.yml +++ b/.github/workflows/issue_triage.yml @@ -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 <> $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"