Skip to content

Commit

Permalink
Merge pull request #10 from 3drepo/main
Browse files Browse the repository at this point in the history
Update the action to use the new output format
  • Loading branch information
benbalter authored Jan 11, 2023
2 parents d511f43 + 387b946 commit 2f7d9b4
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ runs:
else
echo "Using cached project fields metadata from '$FILE_NAME'"
fi
echo "::set-output name=file_name::$FILE_NAME"
echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
- name: Parse content ID, value and title
id: parse_content_metadata
Expand All @@ -133,10 +132,12 @@ runs:
FILE_NAME: ${{ steps.fetch_content_metadata.outputs.file_name }}
run: |
# Parse content metadata
echo '::set-output name=item_id::'$(jq -r '.data.node.projectItems.nodes | .[] | select(.project.number==($PROJECT_NUMBER|fromjson) and .project.owner.login==$OWNER).id' "$FILE_NAME" --arg OWNER "$OWNER" --arg PROJECT_NUMBER "$PROJECT_NUMBER")
echo '::set-output name=item_title::'$(jq -r '.data.node.title' "$FILE_NAME")
echo '::set-output name=item_value::'$(jq -r '.data.node.projectItems.nodes | .[] | select(.project.number==($PROJECT_NUMBER|fromjson) and .project.owner.login==$OWNER).field.value' "$FILE_NAME" --arg OWNER "$OWNER" --arg PROJECT_NUMBER "$PROJECT_NUMBER")
item_id=$(jq -r '.data.node.projectItems.nodes | .[] | select(.project.number==($PROJECT_NUMBER|fromjson) and .project.owner.login==$OWNER).id' "$FILE_NAME" --arg OWNER "$OWNER" --arg PROJECT_NUMBER "$PROJECT_NUMBER")
item_title=$(jq -r '.data.node.title' "$FILE_NAME")
item_value=$(jq -r '.data.node.projectItems.nodes | .[] | select(.project.number==($PROJECT_NUMBER|fromjson) and .project.owner.login==$OWNER).field.value' "$FILE_NAME" --arg OWNER "$OWNER" --arg PROJECT_NUMBER "$PROJECT_NUMBER")
echo "item_id=$item_id" >> $GITHUB_OUTPUT
echo "item_title=$item_title" >> $GITHUB_OUTPUT
echo "item_value=$item_value" >> $GITHUB_OUTPUT
- name: Ensure content item was found
env:
CONTENT_ID: ${{ inputs.content_id }}
Expand Down Expand Up @@ -185,7 +186,7 @@ runs:
echo "Using cached project fields metadata from '$FILE_NAME'"
fi
echo "::set-output name=file_name::$FILE_NAME"
echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
- name: Parse project fields metadata
id: parse_project_fields_metadata
Expand All @@ -196,10 +197,14 @@ runs:
FILE_NAME: ${{ steps.fetch_project_fields_metadata.outputs.file_name }}
run: |
# Parse project metadata
echo '::set-output name=project_id::'$(jq -r '.data.organization.projectV2.id' "$FILE_NAME")
echo '::set-output name=field_id::'$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD) | .id' "$FILE_NAME" --arg FIELD "$FIELD")
echo '::set-output name=field_type::'$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD) | .dataType | ascii_downcase' "$FILE_NAME" --arg FIELD "$FIELD")
echo '::set-output name=option_id::'$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD) | .options[]? | select(.name == $VALUE) | .id' "$FILE_NAME" --arg VALUE "$VALUE" --arg FIELD "$FIELD")
project_id=$(jq -r '.data.organization.projectV2.id' "$FILE_NAME")
field_id=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD) | .id' "$FILE_NAME" --arg FIELD "$FIELD")
field_type=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD) | .dataType | ascii_downcase' "$FILE_NAME" --arg FIELD "$FIELD")
option_id=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name==$FIELD) | .options[]? | select(.name == $VALUE) | .id' "$FILE_NAME" --arg VALUE "$VALUE" --arg FIELD "$FIELD")
echo "project_id=$project_id" >> $GITHUB_OUTPUT
echo "field_id=$field_id" >> $GITHUB_OUTPUT
echo "field_type=$field_type" >> $GITHUB_OUTPUT
echo "option_id=$option_id" >> $GITHUB_OUTPUT
- name: Ensure project, field, and option were found
env:
Expand Down Expand Up @@ -230,20 +235,20 @@ runs:
run: |
# Parse value
if [ "$FIELD_TYPE" = "single_select" ]; then
echo "::set-output name=value_to_set::$OPTION_ID"
echo '::set-output name=value_type::singleSelectOptionId'
echo "value_to_set=$OPTION_ID" >> $GITHUB_OUTPUT
echo 'value_type=singleSelectOptionId' >> $GITHUB_OUTPUT
else
echo "::set-output name=value_to_set::$VALUE"
echo "::set-output name=value_type::$FIELD_TYPE"
echo "value_to_set=$VALUE" >> $GITHUB_OUTPUT
echo "value_type=$FIELD_TYPE" >> $GITHUB_OUTPUT
fi
# Set GraphQL Field Type
if [ "$FIELD_TYPE" = "date" ]; then
echo '::set-output name=value_graphql_type::Date'
echo 'value_graphql_type=Date' >> $GITHUB_OUTPUT
elif [ "$FIELD_TYPE" = "number" ]; then
echo '::set-output name=value_graphql_type::Float'
echo 'value_graphql_type=Float' >> $GITHUB_OUTPUT
else
echo '::set-output name=value_graphql_type::String'
echo 'value_graphql_type=String' >> $GITHUB_OUTPUT
fi
- name: Output values
Expand All @@ -253,9 +258,9 @@ runs:
OPERATION: ${{ inputs.operation }}
run: |
if [ "$OPERATION" == "read" ]; then
echo ''::set-output name=field_updated_value::${{ steps.parse_content_metadata.outputs.item_value }}
echo "field_updated_value="${{ steps.parse_content_metadata.outputs.item_value }} >> $GITHUB_OUTPUT
else
echo ''::set-output name=field_updated_value::${{ inputs.value }}
echo "field_updated_value="${{ inputs.value }} >> $GITHUB_OUTPUT
fi
- name: Update field
Expand Down

0 comments on commit 2f7d9b4

Please sign in to comment.