Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Updated common files in HiromiShikata #176

Updated common files in HiromiShikata

Updated common files in HiromiShikata #176

Workflow file for this run

name: UMINO Project
on:
issues:
types:
- opened
- reopened
- assigned
- unassigned
- labeled
pull_request:
types:
- opened
- reopened
- review_requested
- assigned
- unassigned
- labeled
env:
inbox: Inbox
in_progress: In Progress
gh_project_token: ${{ secrets.GH_TOKEN }}
user: HiromiShikata
project_id: 48
project_v2_id: PVT_kwHOAGJHa84AFWnr
field_id: PVTF_lAHOAGJHa84AFWnrzgIk_H0
jobs:
umino-job:
name: opened_or_reopened
runs-on: ubuntu-latest
if: >-
(github.event_name == 'issues' && github.event.issue.state == 'open') ||
(github.event_name == 'pull_request' && github.event.pull_request.state == 'open') &&
(github.event.action == 'opened' || github.event.action == 'reopened' ||
github.event.action == 'assigned' || github.event.action == 'unassigned' ||
(github.event.action == 'labeled' && github.event.label.name == 'hiromishikata:task:offline'))
steps:
- name: Move issue to ${{ env.inbox }}
uses: leonsteinhaeuser/[email protected]
with:
gh_token: ${{ env.gh_project_token }}
user: ${{ env.user }}
project_id: ${{ env.project_id }}
resource_node_id: ${{ github.event.pull_request.node_id || github.event.issue.node_id }}
status_value: ${{ env.inbox }}
- name: Comment #offline
if: github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'hiromishikata:task:offline'
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueComment = {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '#offline'
};
github.issues.createComment(issueComment);
- run: |
OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
REPO=$(echo ${{ github.repository }} | cut -d '/' -f 2)
ENTITY_TYPE=$(echo ${{ github.event_name }} | grep -q "pull_request" && echo "pullRequest" || echo "issue")
NUMBER=$(echo ${{ github.event_name }} | grep -q "pull_request" && echo ${{ github.event.pull_request.number }} || echo ${{ github.event.issue.number }})
QUERY_DATA='{ "query": "query { repository(owner: \"'$OWNER'\", name: \"'$REPO'\") { '${ENTITY_TYPE}'(number: '$NUMBER') { projectItems(first: 10) { nodes { id } } } } }" }'
RESPONSE=$(curl -X POST -H "Authorization: bearer ${{ secrets.GH_TOKEN }}" -H "Content-Type: application/json" --data "$QUERY_DATA" https://api.github.com/graphql)
if echo $RESPONSE | grep -q "errors"; then
echo "Error in GraphQL query"
echo "GraphQL Response: $RESPONSE"
exit 1
fi
if [ "$ENTITY_TYPE" = "pullRequest" ]; then
ITEM_ID=$(echo $RESPONSE | jq -r '.data.repository.pullRequest.projectItems.nodes[0].id')
else
ITEM_ID=$(echo $RESPONSE | jq -r '.data.repository.issue.projectItems.nodes[0].id')
fi
if [ "$ITEM_ID" = "null" ] || [ -z "$ITEM_ID" ]; then
echo "No valid item ID found, cannot proceed"
exit 1
fi
CLEAR_FIELD_DATA="{\"query\":\"mutation { clearProjectV2ItemFieldValue(input: {projectId: \\\"${{ env.project_v2_id }}\\\", fieldId: \\\"${{ env.field_id }}\\\", itemId: \\\"$ITEM_ID\\\"}) { clientMutationId }}\"}"
CLEAR_RESPONSE=$(curl --request POST \
--url https://api.github.com/graphql \
--header "Authorization: Bearer ${{ env.gh_project_token }}" \
--header "Content-Type: application/json" \
--data "$CLEAR_FIELD_DATA")
if echo $CLEAR_RESPONSE | grep -q "errors"; then
echo "Error in clearing field"
echo "Clear Field Response: $CLEAR_RESPONSE"
exit 1
fi