Update issue automation workflow
This commit is contained in:
parent
0773fe303e
commit
9c8b6bd59b
1 changed files with 64 additions and 18 deletions
82
.github/workflows/project-automation-issue.yaml
vendored
82
.github/workflows/project-automation-issue.yaml
vendored
|
@ -8,7 +8,7 @@ on:
|
||||||
- labeled
|
- labeled
|
||||||
- unlabeled
|
- unlabeled
|
||||||
jobs:
|
jobs:
|
||||||
track_pr:
|
issue_automation:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Get project data
|
- name: Get project data
|
||||||
|
@ -33,11 +33,24 @@ jobs:
|
||||||
}
|
}
|
||||||
}' -f org="$ORGANIZATION" -F number=$PROJECT_NUMBER > project_data.json
|
}' -f org="$ORGANIZATION" -F number=$PROJECT_NUMBER > project_data.json
|
||||||
|
|
||||||
|
echo 'PROJECT_ID='$(jq -r '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Read the ID of the "Type" field options
|
||||||
|
echo 'TYPE_ID='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
echo 'PROJECT_ID='$(jq -r '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
echo 'PROJECT_ID='$(jq -r '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
||||||
echo 'TYPE_ID='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.id' project_data.json) >> $GITHUB_ENV
|
echo 'TYPE_ID='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
echo 'OPTION_FR='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Feature Requests") |.id' project_data.json) >> $GITHUB_ENV
|
echo 'TYPE_BUG='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Bug") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
echo 'OPTION_BUGS='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Bugs") |.id' project_data.json) >> $GITHUB_ENV
|
echo 'TYPE_FEATURE='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Feature") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
echo 'OPTION_DOC='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Documentation") |.id' project_data.json) >> $GITHUB_ENV
|
echo 'TYPE_ENHANCEMENT='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Enhancement") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'TYPE_DOCUMENTATION='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Documentation") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'TYPE_TRANSLATION='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Type") |.settings | fromjson.options[] | select(.name=="Translation") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# Read the id of the "Status" field options
|
||||||
|
echo 'STATUS_ID='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_TODO='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Todo") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_IN_PROGRESS='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="In Progress") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_READY_FOR_REVIEW='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Ready for Review") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_DONE='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name=="Done") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Add Issue to project
|
- name: Add Issue to project
|
||||||
env:
|
env:
|
||||||
|
@ -55,21 +68,54 @@ jobs:
|
||||||
|
|
||||||
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Set "Type" to the Issue
|
- name: Export Labels
|
||||||
|
env:
|
||||||
|
ISSUE_DATA: ${{ toJson(github.event.issue) }}
|
||||||
|
run: |
|
||||||
|
echo 'LABELS=($(echo "$ISSUE_DATA" | jq '.labels[]' | jq -r '.name'))<<EOF' >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set "Type" field
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{secrets.PROJECT_AUTOMATION}}
|
GITHUB_TOKEN: ${{secrets.PROJECT_AUTOMATION}}
|
||||||
run: |
|
run: |
|
||||||
OPTION_ID=$OPTION_BUGS
|
# Only execute this step if the Issue contains at least one label
|
||||||
gh api graphql -f query='
|
if [ "${#LABELS[@]}" -gt 0 ]; then
|
||||||
mutation ($project: ID!, $item: ID!, $field: ID!, $opt_id: ID!) {
|
|
||||||
updateProjectNextItemField(input: {
|
# Let by default the type is "Bug"
|
||||||
projectId: $project
|
OPTION_ID=$TYPE_BUG
|
||||||
itemId: $item
|
|
||||||
fieldId: $field
|
# If it has "feature" label then set the type to "Feature"
|
||||||
value: $opt_id
|
if [[ "${LABELS[*]}" =~ "feature" ]]; then
|
||||||
}) {
|
OPTION_ID=$TYPE_FEATURE
|
||||||
projectNextItem {
|
fi
|
||||||
id
|
|
||||||
|
# If it has "enhancement" label then set the type to "Enhancement"
|
||||||
|
if [[ "${LABELS[*]}" =~ "enhancement" ]]; then
|
||||||
|
OPTION_ID=$TYPE_ENHANCEMENT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it has "documentation" label then set the type to "Documentation"
|
||||||
|
if [[ "${LABELS[*]}" =~ "documentation" ]]; then
|
||||||
|
OPTION_ID=$TYPE_DOCUMENTATION
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If it has "translation" label then set the type to "Translation"
|
||||||
|
if [[ "${LABELS[*]}" =~ "translation" ]]; then
|
||||||
|
OPTION_ID=$TYPE_TRANSLATION
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set the "Type" field to appropriate option
|
||||||
|
gh api graphql -f query='
|
||||||
|
mutation ($project: ID!, $item: ID!, $field: ID!, $opt_id: ID!) {
|
||||||
|
updateProjectNextItemField(input: {
|
||||||
|
projectId: $project
|
||||||
|
itemId: $item
|
||||||
|
fieldId: $field
|
||||||
|
value: $opt_id
|
||||||
|
}) {
|
||||||
|
projectNextItem {
|
||||||
|
id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}' -f project="$PROJECT_ID" -f item="$ITEM_ID" -f field="$TYPE_ID" -f opt_id="$OPTION_ID" --silent
|
||||||
}' -f project="$PROJECT_ID" -f item="$ITEM_ID" -f field="$TYPE_ID" -f opt_id="$OPTION_ID" --silent
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue