From f95ff1c9e3b9ef79e6279e7f3c3bd7ffbf872c34 Mon Sep 17 00:00:00 2001 From: Sara Tavares <29093946+stavares843@users.noreply.github.com> Date: Fri, 4 Oct 2024 10:33:23 +0100 Subject: [PATCH] chore(test): test (#674) --- .../workflows/auto-add-issues-to-project.yml | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/auto-add-issues-to-project.yml b/.github/workflows/auto-add-issues-to-project.yml index 3a2ed9c08..910325628 100644 --- a/.github/workflows/auto-add-issues-to-project.yml +++ b/.github/workflows/auto-add-issues-to-project.yml @@ -7,31 +7,36 @@ on: jobs: add_to_project: runs-on: ubuntu-latest + permissions: + contents: write # Required permission to modify repository contents steps: - name: Add issue to GitHub project uses: actions/github-script@v6 with: script: | - const projectOwner = 'Satellite-im'; - const projectNumber = 19; + const repoOwner = 'Satellite-im'; // Repository owner (Organization or User) + const repoName = 'UplinkWeb'; // Replace with the repository name + const projectNumber = 19; // The number of the project you want to add issues to + const issueId = context.payload.issue.node_id; // The issue ID from the event payload - const issueId = context.payload.issue.node_id; - - const { organization } = await github.graphql(` - query($login: String!, $number: Int!) { - organization(login: $login) { + // GraphQL query to get the project ID from the repository + const { repository } = await github.graphql(` + query($owner: String!, $repo: String!, $number: Int!) { + repository(owner: $owner, name: $repo) { projectV2(number: $number) { id } } } `, { - login: projectOwner, + owner: repoOwner, + repo: repoName, number: projectNumber }); - const projectId = organization.projectV2.id; + const projectId = repository.projectV2.id; // Extract the project ID + // Mutation to add the issue to the project await github.graphql(` mutation($projectId: ID!, $issueId: ID!) { addProjectV2ItemById(input: { projectId: $projectId, contentId: $issueId }) {