π Update CodeTypo #33
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
name: " π Update CodeTypo" | |
on: | |
workflow_dispatch: | |
inputs: | |
base: | |
description: The Base Ref to apply the diff | |
required: false | |
default: "main" | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 12 * * *" | |
permissions: | |
contents: read | |
jobs: | |
update-codetypo: | |
if: github.repository_owner == 'khulnasoft' | |
runs-on: ubuntu-latest | |
env: | |
NEW_BRANCH: update-codetypo-${{ inputs.base || 'main' }} | |
REF_BRANCH: ${{ inputs.base || 'main' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.REF_BRANCH }} | |
- uses: khulnasoft/actions/public/setup-node-pnpm@v1 | |
- name: Install | |
run: pnpm i | |
- name: Update CodeTypo | |
run: | | |
cd action-src | |
echo CODETYPO_VERSION_OLD=$(pnpm exec codetypo -V) >> $GITHUB_ENV | |
pnpm add codetypo@latest codetypo-glob@latest @codetypo/codetypo-bundled-dicts@latest | |
pnpm i | |
pnpm exec codetypo -V | |
echo "CODETYPO_VERSION=$(pnpm exec codetypo -V)" >> $GITHUB_ENV | |
- name: Minor Versions | |
run: | | |
echo CODETYPO_MINOR_OLD=$(echo '"${{ env.CODETYPO_VERSION_OLD }}"' | jq 'sub("\\.[0-9]+$";"")') >> $GITHUB_ENV | |
echo CODETYPO_MINOR_NEW=$(echo '"${{ env.CODETYPO_VERSION }}"' | jq 'sub("\\.[0-9]+$";"")') >> $GITHUB_ENV | |
- name: Determine Update type | |
env: | |
type: ${{ (env.CODETYPO_MINOR_OLD == env.CODETYPO_MINOR_NEW && 'fix') || 'feat' }} | |
run: | | |
echo PR_TYPE=$type >> $GITHUB_ENV | |
- name: Install Updates | |
run: | | |
pnpm i | |
- name: Clean Build | |
run: | | |
pnpm clean | |
pnpm build | |
- name: Git Status | |
id: git-status | |
uses: khulnasoft/actions/public/dirty@v1 | |
- name: Echo git_status | |
env: | |
REPORT: | | |
Dirty: ${{ steps.git-status.outputs.isDirty && 'yes' || 'no' }} | |
CodeTypo Version: ${{ env.CODETYPO_VERSION }} | |
Old Version: ${{ env.CODETYPO_VERSION_OLD }} | |
run: | | |
echo "$REPORT" | |
- name: CodeTypo Version Msg | |
id: codetypo_version_msg | |
uses: khulnasoft/actions/public/output@v1 | |
with: | |
value: CodeTypo version (${{ env.CODETYPO_VERSION }}) | |
- name: Commit Message | |
id: commit_message | |
uses: khulnasoft/actions/public/output@v1 | |
with: | |
value: >- | |
Update ${{ env.CODETYPO_VERSION == env.CODETYPO_VERSION_OLD && 'Dictionaries and Dependencies' || steps.codetypo_version_msg.outputs.value }} | |
- name: Gen PR Body | |
id: body | |
uses: khulnasoft/actions/public/pr-body@v1 | |
with: | |
title: ${{ steps.commit_message.outputs.value }} | |
message: | | |
**CodeTypo Version:** ${{ env.CODETYPO_VERSION_OLD }} -> ${{ env.CODETYPO_VERSION }} | |
**Type:** ${{ env.PR_TYPE }} | |
path: >- | |
package.json | |
action-src/package.json | |
action/package.json | |
- name: Show Summary | |
uses: khulnasoft/actions/public/summary@v1 | |
with: | |
text: | | |
${{ steps.body.outputs.body }} | |
**Status:** ${{ steps.git-status.outputs.isDirty && 'dirty' || 'clean' }} | |
## Changes: | |
``` | |
${{ steps.git-status.outputs.status }} | |
``` | |
- name: PR | |
if: steps.git-status.outputs.isDirty | |
uses: khulnasoft/actions/.github/actions/pr@v1 | |
with: | |
commit-message: "${{ env.PR_TYPE }}: ${{ steps.commit_message.outputs.value }}" | |
branch: ${{ env.NEW_BRANCH }} | |
base: ${{ env.REF_BRANCH }} | |
title: "${{ env.PR_TYPE }}: ${{ steps.commit_message.outputs.value }}" | |
body: ${{ steps.body.outputs.body }} | |
app_id: ${{ secrets.AUTOMATION_APP_ID }} | |
app_private_key: ${{ secrets.AUTOMATION_PRIVATE_KEY }} |