From 7fc49b53727d61889236cee6192afafd5f4adf89 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 9 Jan 2024 02:29:10 +0000 Subject: [PATCH 1/2] autogen: updated common files in HiromiShikata --- .github/workflows/commit-lint.yml | 2 +- .../workflows/configs/commitlint.config.js | 1 + .github/workflows/create-pr.yml | 10 ++--- .github/workflows/empty-format-test-job.yml | 23 ++++++++--- .github/workflows/umino-project.yml | 41 +++++++++++++++++++ 5 files changed, 65 insertions(+), 12 deletions(-) diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml index 10f644e..4c72bef 100644 --- a/.github/workflows/commit-lint.yml +++ b/.github/workflows/commit-lint.yml @@ -19,7 +19,7 @@ jobs: - name: Lint commits run: | - npx commitlint --from=HEAD~1 --to=HEAD --config ./.github/workflows/configs/commitlint.config.js + npx commitlint --from=origin/main --to=HEAD --config ./.github/workflows/configs/commitlint.config.js check-dontmerge: runs-on: ubuntu-latest diff --git a/.github/workflows/configs/commitlint.config.js b/.github/workflows/configs/commitlint.config.js index 335f922..04a6c34 100644 --- a/.github/workflows/configs/commitlint.config.js +++ b/.github/workflows/configs/commitlint.config.js @@ -16,6 +16,7 @@ module.exports = { 'style', 'test', 'autogen', + 'prep', ] ], } diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml index 8e97978..e38d368 100644 --- a/.github/workflows/create-pr.yml +++ b/.github/workflows/create-pr.yml @@ -21,10 +21,10 @@ jobs: uses: repo-sync/pull-request@v2 with: github_token: ${{ secrets.GH_TOKEN }} - destination_branch: 'main' - source_branch: '' - pr_title: '${{ steps.branch_name.outputs.branch }}' - pr_body: 'This is an auto-create PR.' + destination_branch: "main" + source_branch: "" + pr_title: "${{ steps.branch_name.outputs.branch }}" + pr_body: "This is an auto-create PR." draft: false - name: Assign PR to author @@ -40,7 +40,7 @@ jobs: if: steps.create_pr.outputs.pr_number id: get_pr_id run: | - PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create_pr.outputs.pr_number }}") + PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create_pr.outputs.pr_number }}") PR_ID=$(echo "$PR_DATA" | jq -r '.node_id') echo "::set-output name=node_id::$PR_ID" diff --git a/.github/workflows/empty-format-test-job.yml b/.github/workflows/empty-format-test-job.yml index 7955c06..c6005d0 100644 --- a/.github/workflows/empty-format-test-job.yml +++ b/.github/workflows/empty-format-test-job.yml @@ -1,15 +1,26 @@ name: Empty format test -on: - push +on: push jobs: - format: - runs-on: ubuntu-latest - steps: - - run: echo "format" test: runs-on: ubuntu-latest steps: - run: echo "test" + format: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GH_TOKEN }} + - uses: actions/setup-node@v4 + with: + node-version: 20 + - run: git pull + - run: npx prettier --write "**/*.{md,yaml,yml}" && git --no-pager diff + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: 'style: re-format / npx prettier --write "**/*.{md,yaml,yml}"' diff --git a/.github/workflows/umino-project.yml b/.github/workflows/umino-project.yml index 297552e..4608fdd 100644 --- a/.github/workflows/umino-project.yml +++ b/.github/workflows/umino-project.yml @@ -22,6 +22,8 @@ env: gh_project_token: ${{ secrets.GH_TOKEN }} user: HiromiShikata project_id: 48 + project_v2_id: PVT_kwHOAGJHa84AFWnr + field_id: PVTF_lAHOAGJHa84AFWnrzgIk_H0 jobs: umino-job: @@ -55,3 +57,42 @@ jobs: 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 From 3099b896a10b9c5443d9334256b357c3a60b4d29 Mon Sep 17 00:00:00 2001 From: HiromiShikata Date: Tue, 9 Jan 2024 02:32:10 +0000 Subject: [PATCH 2/2] style: re-format / npx prettier --write "**/*.{md,yaml,yml}" --- .github/workflows/create-pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml index e38d368..0c9fb63 100644 --- a/.github/workflows/create-pr.yml +++ b/.github/workflows/create-pr.yml @@ -21,10 +21,10 @@ jobs: uses: repo-sync/pull-request@v2 with: github_token: ${{ secrets.GH_TOKEN }} - destination_branch: "main" - source_branch: "" - pr_title: "${{ steps.branch_name.outputs.branch }}" - pr_body: "This is an auto-create PR." + destination_branch: 'main' + source_branch: '' + pr_title: '${{ steps.branch_name.outputs.branch }}' + pr_body: 'This is an auto-create PR.' draft: false - name: Assign PR to author