Skip to content

Commit

Permalink
Merge pull request #11 from Avivbens/setup-new-action-for-release-check
Browse files Browse the repository at this point in the history
chore: semantic report for each pr
  • Loading branch information
Avivbens authored Jan 18, 2024
2 parents 2de60af + 5f114f1 commit 66790ac
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 45 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/health-check/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,8 @@ inputs:
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
- name: 🖥️ Setup Env
uses: ./.github/workflows/install

- name: 🧪 Test
if: ${{ inputs.run-tests == 'true' }}
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/install/action.yaml
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
28 changes: 0 additions & 28 deletions .github/workflows/pr-checks.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,3 @@ jobs:

- name: 🧪 Check out repository code
uses: ./.github/workflows/health-check

- 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: |
let fromBuffer = Buffer.from('${{ steps.semantic-release.outputs.releaseNote }}', 'base64').toString('utf8');
let releaseNote = fromBuffer.split('\n').filter((line) => !line.match(/^[[0-9:\sAMPM]+\]\s\[semantic-release\].*$/));
let res = releaseNote.join('\n');
if (!releaseNote.length || !res) {
return;
}
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `The new semantic report is: \n ${res}`,
})
66 changes: 66 additions & 0 deletions .github/workflows/release-check.yaml
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,
})
10 changes: 2 additions & 8 deletions .github/workflows/release-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,8 @@ jobs:
git config --global user.name "github-bot"
git config --global user.email "github-bot@gmail.com"
- 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
Expand Down

0 comments on commit 66790ac

Please sign in to comment.