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

Commit

Permalink
autogen: updated common files in HiromiShikata
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user authored and HiromiShikata committed Nov 20, 2023
1 parent 4b49c71 commit 091fa72
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 10 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint Commit Messages
on: push

jobs:
commit-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4

- name: Install commitlint
run: |
npm install --save-dev @commitlint/{config-conventional,cli}
- name: Lint commits
run: |
npx commitlint --from=HEAD~1 --to=HEAD --config ./.github/workflows/configs/commitlint.config.js
check-dontmerge:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for DONTMERGE
run: |
result=$(find . \
-type f \
! -path './.github/workflows/commit-lint.yml' \
! -name '*.snap' \
-exec grep -Hn 'DONTMERGE' {} \;)
if [[ ! -z "$result" ]]; then
echo "$result"
exit 1
fi
22 changes: 22 additions & 0 deletions .github/workflows/configs/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
rules: {
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'autogen',
]
],
}
};
64 changes: 56 additions & 8 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,64 @@
name: Run the Action on each commit
name: Create PR

on:
push:
branches-ignore: main
branches-ignore:
- main

jobs:
action-pull-request:
create_and_enable_automerge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create pull request
uses: devops-infra/[email protected]

- name: Set branch name as output
id: branch_name
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"

- name: Create Pull Request
id: create_pr
uses: repo-sync/pull-request@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reviewer: HiromiShikata
target_branch: main
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.'
draft: false

- name: Assign PR to author
if: steps.create_pr.outputs.pr_number
run: |
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"assignees":["${{ github.actor }}"]}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.create_pr.outputs.pr_number }}/assignees"
- name: Get PR Node ID
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_ID=$(echo "$PR_DATA" | jq -r '.node_id')
echo "::set-output name=node_id::$PR_ID"
- name: Enable Auto Merge for PR
if: steps.create_pr.outputs.pr_number
run: |
RESPONSE=$(curl -s -X POST \
-H "Authorization: bearer ${{ secrets.GH_TOKEN }}" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation($id: ID!) { enablePullRequestAutoMerge(input: { pullRequestId: $id }) { clientMutationId } }",
"variables": {
"id": "'"${{ steps.get_pr_id.outputs.node_id }}"'"
}
}' \
"https://api.github.com/graphql")
echo "$RESPONSE"
if echo "$RESPONSE" | jq -e '.errors' >/dev/null; then
echo "Failed to enable auto merge"
exit 1
fi
15 changes: 15 additions & 0 deletions .github/workflows/empty-format-test-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Empty format test

on:
push

jobs:
format:
runs-on: ubuntu-latest
steps:
- run: echo "format"
test:
runs-on: ubuntu-latest
steps:
- run: echo "test"

20 changes: 18 additions & 2 deletions .github/workflows/umino-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ on:
- reopened
- assigned
- unassigned
- labeled
pull_request:
types:
- opened
- reopened
- review_requested
- assigned
- unassigned
- labeled

env:
inbox: Inbox
Expand All @@ -22,14 +24,15 @@ env:
project_id: 48

jobs:
move_to_inbox:
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 == '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]
Expand All @@ -39,3 +42,16 @@ jobs:
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);

0 comments on commit 091fa72

Please sign in to comment.