Skip to content

Sometimes first/last name fields are not present in AGOL so need to handle when only fullName is available #103

Sometimes first/last name fields are not present in AGOL so need to handle when only fullName is available

Sometimes first/last name fields are not present in AGOL so need to handle when only fullName is available #103

# This is a basic workflow to help you get started with Actions
name: Add New Issues to Org Project
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
issues:
types:
- opened
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
track_issue:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Get project data
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACCESS }}
ORGANIZATION: USEPA
PROJECT_NUMBER: 10
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
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
# Runs a set of commands using the runners shell
- name: Add new issue to project
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACCESS }}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql -f query='
mutation($project:ID!, $issue:ID!) {
addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.projectV2Item.id')"