From 8e53306bc4a1b121f59b5a3fb7ad26933d1aa4d6 Mon Sep 17 00:00:00 2001 From: Padmaja <52911293+padms@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:13:01 +0530 Subject: [PATCH] TEst #2755 --- .github/workflows/project/action.yaml | 84 +++++++++++++++++++++++++++ .github/workflows/test-workflow.yaml | 11 ++++ 2 files changed, 95 insertions(+) create mode 100644 .github/workflows/project/action.yaml create mode 100644 .github/workflows/test-workflow.yaml diff --git a/.github/workflows/project/action.yaml b/.github/workflows/project/action.yaml new file mode 100644 index 000000000..0130ce1c3 --- /dev/null +++ b/.github/workflows/project/action.yaml @@ -0,0 +1,84 @@ +# This workflow runs whenever a pull request in the repository is marked as "ready for review". +name: Move issue/PR to ✅ Done status +description: 'Move issue' +runs: + using: 'composite' + steps: + # Sets environment variables for this step. + # + # If you are using a personal access token, replace `YOUR_TOKEN` with the name of the secret that contains your personal access token. + # + # Replace `YOUR_ORGANIZATION` with the name of your organization. For example, `octo-org`. + # + # Replace `YOUR_PROJECT_NUMBER` with your project number. To find the project number, look at the project URL. For example, `https://github.com/orgs/octo-org/projects/5` has a project number of 5. + - name: Get project data + shell: 'bash' + env: + GH_TOKEN: ${{ secrets.PADMS_PAT }} + ORGANIZATION: 'equinor' + PROJECT_NUMBER: 965 + # Uses [GitHub CLI](https://cli.github.com/manual/) to query the API for the ID of the project and return the name and ID of the first 20 fields in the project. `fields` returns a union and the query uses inline fragments (`... on`) to return information about any `ProjectV2Field` and `ProjectV2SingleSelectField` fields. The response is stored in a file called `project_data.json`. + run: | + gh api graphql -f query=' + query($org: String!, $number: Int!) { + organization(login: $org){ + projectV2(number: $number) { + id + fields(first:20) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json + + # Parses the response from the API query and stores the relevant IDs as environment variables. Modify this to get the ID for different fields or options. For example: + # + # - To get the ID of a field called `Team`, add `echo 'TEAM_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Team") | .id' project_data.json) >> $GITHUB_ENV`. + # - To get the ID of an option called `Octoteam` for the `Team` single select field, add `echo 'OCTOTEAM_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Team") |.options[] | select(.name=="Octoteam") |.id' project_data.json) >> $GITHUB_ENV`. + # + # **Note:** This workflow assumes that you have a project with a single select field called "Status" that includes an option called "✅ Done" and a date field called "Date posted". You must modify this section to match the fields that are present in your table. + + echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV + echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV + echo 'RELEASE_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="🚀 Release") |.id' project_data.json) >> $GITHUB_ENV + echo 'DONE_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="✅ Done") |.id' project_data.json) >> $GITHUB_ENV + + # Sets environment variables for this step. Replace `YOUR_TOKEN` with the name of the secret that contains your personal access token. + # - name: Set fields + # env: + # GH_TOKEN: ${{ secrets.PADMS_PAT }} + # # Sets the value of the `Status` field to `🚀 Release`. + # run: | + # gh api graphql -f query=' + # mutation ( + # $project: ID! + # $item: ID! + # $status_field: ID! + # $status_value: String! + # ) { + # set_status: updateProjectV2ItemFieldValue(input: { + # projectId: $project + # itemId: $item + # fieldId: $status_field + # value: { + # singleSelectOptionId: $status_value + # } + # }) { + # projectV2Item { + # id + # } + # } + # }' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.RELEASE_OPTION_ID }} --silent diff --git a/.github/workflows/test-workflow.yaml b/.github/workflows/test-workflow.yaml new file mode 100644 index 000000000..29efa9884 --- /dev/null +++ b/.github/workflows/test-workflow.yaml @@ -0,0 +1,11 @@ +name: 'Test workflow for setting up project workflows' +on: + workflow_dispatch: + +jobs: + get-list: + runs-on: 'ubuntu-latest' + steps: + - name: 'GEt list' + id: 'get-list' + uses: ./.github/workflows/project/