-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Avivbens/setup-new-action-for-release-check
chore: semantic report for each pr
- Loading branch information
Showing
5 changed files
with
86 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
name: '☑️ Install deps' | ||
description: 'Install dependencies and setup node' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: 🖥️ Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: 🔗 Install Dependencies | ||
shell: bash | ||
run: | | ||
npm ci --no-fund --no-audit --ignore-scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
name: Semantic Release Check 📝 | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
PR-checks: | ||
# https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/using-self-hosted-runners-in-a-workflow | ||
runs-on: ubuntu-latest | ||
name: Semantic Release Check 📝 | ||
steps: | ||
- name: 📀 Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: 🖥️ Setup Env | ||
uses: ./.github/workflows/install | ||
|
||
- name: 🔬 Check semantic versioning | ||
id: semantic-release | ||
run: | | ||
GITHUB_REF=${{ github.head_ref }} | ||
npx semantic-release --no-ci --dry-run --plugins @semantic-release/commit-analyzer,@semantic-release/release-notes-generator --branches ${{ github.head_ref }} > output.txt | ||
OUTPUT=$(cat output.txt | base64 -w 0) | ||
echo "::set-output name=releaseNote::$OUTPUT" | ||
- name: 📝 Report semantic versioning | ||
uses: actions/github-script@v3 | ||
if: ${{ steps.semantic-release.outputs.releaseNote != '' }} | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
// build release note | ||
const fromBuffer = Buffer.from('${{ steps.semantic-release.outputs.releaseNote }}', 'base64').toString('utf8'); | ||
const matchRegex = /^[[0-9:\sAMPM]+\]\s\[semantic-release\].*$/; | ||
const releaseNote = fromBuffer.split('\n').filter((line) => !line.match(matchRegex)); | ||
const res = releaseNote.join('\n'); | ||
if (!releaseNote.length || !res) { | ||
return; | ||
} | ||
const body = `The new semantic report is: \n ${res}`; | ||
// get last comment | ||
const comments = await github.issues.listComments({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const alreadyCommented = comments.data.find((comment) => comment.body === body); | ||
if (alreadyCommented) { | ||
return; | ||
} | ||
github.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,14 +52,8 @@ jobs: | |
git config --global user.name "github-bot" | ||
git config --global user.email "[email protected]" | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
npm ci --no-fund --no-audit --ignore-scripts | ||
- name: 🖥️ Setup Env | ||
uses: ./.github/workflows/install | ||
|
||
- name: Build | ||
run: npm run build | ||
|