Skip to content

Commit

Permalink
Merge pull request #56 from vusion/task-404-cw_echarts_library-hanshi…
Browse files Browse the repository at this point in the history
…jie-240226

Task 404 auto changelog support hanshijie 240226
  • Loading branch information
ncqwer authored Feb 26, 2024
2 parents e5a6dd7 + 39424e9 commit 0c14e7e
Show file tree
Hide file tree
Showing 14 changed files with 38,158 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Generate Commit on Comment with Pull Request

on:
issue_comment:
types: [created]

permissions:
pull-requests: write
contents: write
issues: write

jobs:
generate-commit:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/generate-commit')
runs-on: ubuntu-latest

steps:
# - name: Get branch name
# id: branch_name
# run: |
# branch_name=$(curl -s -H "Authorization: token ${{ github.token }}" ${{github.event.issue.pull_request.url}} | jq -r '.head.ref')
# echo $branch_name
- name: Checkout
uses: actions/checkout/@v3
with:
fetch-depth: 0
- name: Add comment with workflow run link
run: |
COMMENT_BODY="The workflow run can be found at $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
curl -d '{"body":"'"$COMMENT_BODY"'"}' -H "Content-Type: application/json" -H "Authorization: Bearer ${{github.token}}" -X POST "https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ github.event.issue.number }}/comments"
env:
GITHUB_SERVER_URL: ${{ github.server_url }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}

- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
branch_name=$(curl -s -H "Authorization: token ${{ github.token }}" ${{github.event.issue.pull_request.url}} | jq -r '.head.ref')
git checkout -b $branch_name origin/$branch_name
env:
GITHUB_TOKEN: ${{ github.token}}

- name: Setup Nodejs
uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16

- name: Install yarn
run: npm install -g yarn@v1

- name: Install Dep
run: |
yarn install --frozen-lockfile
- name: Update Pull Request
run: |
yarn changelog:comment
env:
GITHUB_TOKEN: ${{ github.token}}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
56 changes: 56 additions & 0 deletions .github/workflows/update-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Update Pull Request Body

on:
pull_request:
branches: main

permissions:
pull-requests: write

jobs:
update-pr:
runs-on: ubuntu-latest

steps:
- name: Check if commit is from CI
run: |
if [[ "${{ github.event.head_commit.committer.username }}" == "github-actions[bot]" ]]; then
echo "Commit is from CI, skipping the build..."
exit 78
else
echo "Commit is not from CI, continuing with the build..."
fi
- name: Checkout
uses: actions/checkout/@v3
with:
fetch-depth: 0

- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
git checkout -b main origin/main
git checkout '${{github.event.pull_request.head.ref}}'
env:
GITHUB_TOKEN: ${{ github.token}}

- name: Setup Nodejs
uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16

- name: Install yarn
run: npm install -g yarn@v1

- name: Install Dep
run: |
yarn install --frozen-lockfile
- name: Update Pull Request
run: |
yarn changelog:ci
env:
GITHUB_TOKEN: ${{ github.token}}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ yarn-error.log*

# Locks
# package-lock.json
yarn.lock
*/**/yarn.lock
*/yarn.lock

# Cache
.DS_Store
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "cloud-ui-materials",
"private": "true",
"scripts": {
"changelog": "node scripts/changelog.js",
"changelog:ci": "node scripts/changelog.js from-ci",
"changelog:comment": "node scripts/changelog.js from-comment"
},
"dependencies": {
"lodash.mergewith": "^4.6.2",
"node-fetch": "2"
}
}
Loading

0 comments on commit 0c14e7e

Please sign in to comment.