diff --git a/.github/workflows/health-check/action.yaml b/.github/workflows/health-check/action.yaml index 0fadbc5..1ad6e2c 100644 --- a/.github/workflows/health-check/action.yaml +++ b/.github/workflows/health-check/action.yaml @@ -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' }} diff --git a/.github/workflows/install/action.yaml b/.github/workflows/install/action.yaml new file mode 100644 index 0000000..45720e2 --- /dev/null +++ b/.github/workflows/install/action.yaml @@ -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 diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml old mode 100644 new mode 100755 index d060bb6..b54da90 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -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}`, - }) diff --git a/.github/workflows/release-check.yaml b/.github/workflows/release-check.yaml new file mode 100755 index 0000000..a50979c --- /dev/null +++ b/.github/workflows/release-check.yaml @@ -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, + }) diff --git a/.github/workflows/release-master.yaml b/.github/workflows/release-master.yaml index 0813f0d..a020cc9 100644 --- a/.github/workflows/release-master.yaml +++ b/.github/workflows/release-master.yaml @@ -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