From a5b740f488a924d9e484110b66bd8389c1a57e83 Mon Sep 17 00:00:00 2001 From: Hardeep Asrani Date: Sat, 13 Jul 2024 05:19:23 +0530 Subject: [PATCH] Add GH actions --- .github/workflows/create-buld-url.yml | 100 ++++++++++++++++++++++++++ .github/workflows/create-tag.yml | 44 ++++++++++++ .github/workflows/deploy.yml | 52 ++++++++++++++ .github/workflows/issue-labeler.yml | 14 ++++ .github/workflows/new-issues.yml | 42 +++++++++++ .github/workflows/sync-branches.yml | 31 ++++++++ .github/workflows/test-js.yml | 29 ++++++++ .github/workflows/test-php.yml | 62 ++++++++++++++++ CHANGELOG.md | 0 README.md | 2 - readme.txt | 35 +++++++++ 11 files changed, 409 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/create-buld-url.yml create mode 100644 .github/workflows/create-tag.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/issue-labeler.yml create mode 100644 .github/workflows/new-issues.yml create mode 100644 .github/workflows/sync-branches.yml create mode 100644 .github/workflows/test-js.yml create mode 100644 .github/workflows/test-php.yml create mode 100644 CHANGELOG.md delete mode 100644 README.md create mode 100644 readme.txt diff --git a/.github/workflows/create-buld-url.yml b/.github/workflows/create-buld-url.yml new file mode 100644 index 0000000..4652def --- /dev/null +++ b/.github/workflows/create-buld-url.yml @@ -0,0 +1,100 @@ +name: Build and publish the ZIP build file + +on: + pull_request: + types: [opened, synchronize, ready_for_review] + branches-ignore: + - 'update_dependencies' +jobs: + dev-zip: + name: Build ZIP and upload to s3 + if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name + runs-on: ubuntu-latest + outputs: + branch-name: ${{ steps.retrieve-branch-name.outputs.branch_name }} + git-sha-8: ${{ steps.retrieve-git-sha-8.outputs.sha8 }} + steps: + - name: Check out source files + uses: actions/checkout@v2 + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Configure Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install composer deps + run: composer install --no-dev --prefer-dist --no-progress --no-suggest + - name: Install npm deps + run: npm ci + - name: Build files + run: npm run build + - name: Create zip + run: npm run dist + - name: Retrieve branch name + id: retrieve-branch-name + run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" + - name: Retrieve git SHA-8 string + id: retrieve-git-sha-8 + run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)" + - name: Upload Latest Version to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_DEV_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.S3_AWS_KEY_ARTIFACTS }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_AWS_SECRET_ARTIFACTS }} + SOURCE_DIR: artifact/ + DEST_DIR: ${{ github.event.pull_request.base.repo.name }}-${{ steps.retrieve-branch-name.outputs.branch_name }}-${{ steps.retrieve-git-sha-8.outputs.sha8 }}/ + + comment-on-pr: + name: Comment on PR with links to plugin ZIPs + if: ${{ github.head_ref && github.head_ref != null }} + runs-on: ubuntu-latest + needs: dev-zip + env: + CI: true + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + outputs: + pr_number: ${{ steps.get-pr-number.outputs.num }} + comment_body: ${{ steps.get-comment-body.outputs.body }} + steps: + - name: Get PR number + id: get-pr-number + run: echo "::set-output name=num::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" + + - name: Check if a comment was already made + id: find-comment + uses: peter-evans/find-comment@v2 + with: + issue-number: ${{ steps.get-pr-number.outputs.num }} + comment-author: github-actions[bot] + body-includes: Download Plugin - [Download] + + - name: Get comment body + id: get-comment-body + run: | + body="Plugin build for ${{ github.event.pull_request.head.sha }} is ready :bellhop_bell:! + - Download Plugin - [Download](https://verti-artifacts.s3.amazonaws.com/${{ github.event.pull_request.base.repo.name }}-${{ needs.dev-zip.outputs.branch-name }}-${{ needs.dev-zip.outputs.git-sha-8 }}/hyve-lite.zip)" + body="${body//$'\n'/'%0A'}" + echo "::set-output name=body::$body" + + - name: Create comment on PR with links to plugin builds + if: ${{ steps.find-comment.outputs.comment-id == '' }} + uses: peter-evans/create-or-update-comment@v2 + with: + issue-number: ${{ steps.get-pr-number.outputs.num }} + body: ${{ steps.get-comment-body.outputs.body }} + + - name: Update comment on PR with links to plugin builds + if: ${{ steps.find-comment.outputs.comment-id != '' }} + uses: peter-evans/create-or-update-comment@v2 + with: + comment-id: ${{ steps.find-comment.outputs.comment-id }} + edit-mode: replace + body: ${{ steps.get-comment-body.outputs.body }} diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml new file mode 100644 index 0000000..29cab36 --- /dev/null +++ b/.github/workflows/create-tag.yml @@ -0,0 +1,44 @@ +name: Release + +on: + push: + branches: + - main +jobs: + create_tag: + runs-on: ubuntu-latest + if: "! contains(github.event.head_commit.message, '[skip ci]')" + strategy: + matrix: + node-version: [20.x] + steps: + - uses: actions/checkout@master + with: + persist-credentials: false + - name: Build files using ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Release new version + id: release + run: | + npm ci + npm run release + env: + CI: true + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + GIT_AUTHOR_NAME: themeisle[bot] + GIT_AUTHOR_EMAIL: ${{ secrets.BOT_EMAIL }} + GIT_COMMITTER_NAME: themeisle[bot] + GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_ANNOUNCEMENTS }} + SEMANTIC_RELEASE_PACKAGE: Hyve Lite + empty-job: + # if no jobs run, github action considers it a test failure -- which seems like a bug + # this makes it so the top-level if statement for the job does not give status failure. + runs-on: ubuntu-latest + if: success() + steps: + - name: Meep + run: | + echo "Nothing to do" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7dd11b6 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: Deploy +on: + push: + tags: + - "*" +jobs: + tag: + name: Deploy to WordPress.org + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} + - name: Install composer deps + run: composer install --no-dev --prefer-dist --no-progress --no-suggest + - name: Install npm deps + run: npm ci + - name: Build files + run: npm run build + - name: Build zip + run: npm run dist + - name: Upload Latest Version to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DOWNLOADS }} + AWS_ACCESS_KEY_ID: ${{ secrets.S3_DOWNLOADS_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DOWNLOADS_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: 'us-west-1' # optional: defaults to us-east-1 + SOURCE_DIR: 'artifact' # optional: defaults to entire repository + DEST_DIR: ${{ secrets.S3_AWS_PRODUCTS_FOLDER }}/hyve-lite/latest + - name: Upload Tagged Version to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_DOWNLOADS }} + AWS_ACCESS_KEY_ID: ${{ secrets.S3_DOWNLOADS_AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_DOWNLOADS_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: 'us-west-1' # optional: defaults to us-east-1 + SOURCE_DIR: 'artifact' # optional: defaults to entire repository + DEST_DIR: ${{ secrets.S3_AWS_PRODUCTS_FOLDER }}/hyve-lite/$BUILD_VERSION + - name: Send update to the store + env: + PRODUCT_ID: ${{ secrets.THEMEISLE_ID }} + AUTH_TOKEN: ${{ secrets.THEMEISLE_STORE_AUTH }} + STORE_URL: ${{ secrets.THEMEISLE_STORE_URL }} + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + BUILD_VERSION: ${{ steps.get_version.outputs.VERSION }} + uses: Codeinwp/action-store-release@main diff --git a/.github/workflows/issue-labeler.yml b/.github/workflows/issue-labeler.yml new file mode 100644 index 0000000..73283e3 --- /dev/null +++ b/.github/workflows/issue-labeler.yml @@ -0,0 +1,14 @@ +name: "Issue Labeler" +on: + issues: + types: [opened] + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: github/issue-labeler@master + with: + repo-token: "${{ secrets.BOT_TOKEN }}" + enable-versioned-regex: 0 + configuration-path: .github/labeler.yml \ No newline at end of file diff --git a/.github/workflows/new-issues.yml b/.github/workflows/new-issues.yml new file mode 100644 index 0000000..821e881 --- /dev/null +++ b/.github/workflows/new-issues.yml @@ -0,0 +1,42 @@ +name: Add to project + +on: + issues: + types: [opened,transferred] + +jobs: + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@main + id: add_project + with: + project-url: ${{ secrets.PROJECT_PLANNING }} + github-token: ${{ secrets.BOT_TOKEN_PROJECT }} + - name: Set Team + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN_PROJECT }} + run: | + gh api graphql -f query=' + mutation( + $project: ID! + $item: ID! + $status_field: ID! + $status_value: String! + ) { + updateProjectV2ItemFieldValue( + input: { + projectId: $project + itemId: $item + fieldId: $status_field + value: { + singleSelectOptionId: $status_value + } + } + ) { + projectV2Item { + id + } + } + }' -f project=${{ secrets.PROJECT_PLANNING_ID }} -f item=${{ steps.add_project.outputs.itemId }} -f status_field=${{ secrets.PLANNING_TEAM_FIELD_ID }} -f status_value=620890b9 --silent \ No newline at end of file diff --git a/.github/workflows/sync-branches.yml b/.github/workflows/sync-branches.yml new file mode 100644 index 0000000..cd40bd9 --- /dev/null +++ b/.github/workflows/sync-branches.yml @@ -0,0 +1,31 @@ +name: Sync branches +on: + push: + branches: + - 'master' + - 'development' +jobs: + sync-branch: + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'Codeinwp' }} # Disable on forks + steps: + - uses: actions/checkout@master + - name: Retrieve branch name + id: retrieve-branch-name + run: echo "::set-output name=branch_name::$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" + - name: Merge master -> development + if: ${{ steps.retrieve-branch-name.outputs.branch_name == 'master' }} + uses: Codeinwp/merge-branch@master + with: + type: now + from_branch: master + target_branch: development + github_token: ${{ secrets.BOT_TOKEN }} + - name: Merge development -> next + if: ${{ steps.retrieve-branch-name.outputs.branch_name == 'development' }} + uses: Codeinwp/merge-branch@master + with: + type: now + from_branch: development + target_branch: next + github_token: ${{ secrets.BOT_TOKEN }} diff --git a/.github/workflows/test-js.yml b/.github/workflows/test-js.yml new file mode 100644 index 0000000..3888dc7 --- /dev/null +++ b/.github/workflows/test-js.yml @@ -0,0 +1,29 @@ +name: Test JS + +on: + pull_request: + types: [opened, synchronize, ready_for_review] + +jobs: + run: + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name + strategy: + matrix: + node-version: [20.x] + name: JS Test + steps: + - uses: actions/checkout@master + with: + persist-credentials: false + - name: Build files using ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Lint js files + run: | + npm install -g npm + npm ci + npm run lint:js + env: + CI: true diff --git a/.github/workflows/test-php.yml b/.github/workflows/test-php.yml new file mode 100644 index 0000000..46998ce --- /dev/null +++ b/.github/workflows/test-php.yml @@ -0,0 +1,62 @@ +name: Test PHP + +on: + pull_request: + types: [opened, synchronize, ready_for_review] + +jobs: + phplint: + name: PHPLint + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name + steps: + - name: Setup PHP version + uses: shivammathur/setup-php@v1 + with: + php-version: '7.4' + extensions: simplexml + - name: Checkout source code + uses: actions/checkout@v2 + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Setup Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install composer + run: composer install --prefer-dist --no-progress --no-suggest + - name: Run PHPCS + run: composer run lint + + phpstan: + name: PHPStan + runs-on: ubuntu-latest + if: github.event.pull_request.draft == false && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name + steps: + - name: Setup PHP version + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: simplexml, mysql + - name: Checkout source code + uses: actions/checkout@v2 + - name: Get Composer Cache Directory + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Setup Composer cache + uses: actions/cache@v1 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + - name: Install composer + run: composer install --prefer-dist --no-progress --no-suggest + - name: PHPStan Static Analysis + run: composer phpstan diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md deleted file mode 100644 index 0c8ddf5..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# hyve-lite -An AI Chat plugin for WordPress diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..427640f --- /dev/null +++ b/readme.txt @@ -0,0 +1,35 @@ +=== Hyve Lite === +Contributors: themeisle, hardeepasrani +Tags: automation, support, chat, ai, openai +Requires at least: 6.2 +Tested up to: 6.5 +Requires PHP: 5.6 +Stable tag: trunk +License: GPLv3 +License URI: https://www.gnu.org/licenses/gpl-3.0.en.html + +Hyve Description + +== Description == + +== Screenshots == + +== Installation == + +#### Automatic Installation + +To download and install the Hyve plugin, make sure you follow the steps below: + +- Navigate to the WordPress Dashboard > Plugins. +- Click the Add New button and type in the Search Bar "Hyve Lite". +- When the plugin appears, click on the Install button and then on Activate. + +#### Manual Installation + +- Log into your website admin page, then go to Appearance > Plugins. You will see all the plugins currently installed in your dashboard listed there. +- To install a new WordPress plugin, simply click on the Add New tab. +- Click the Upload Plugin button in the WordPress Dashboard. +- Click the Choose File button, select the ZIP archive of the Hyve Lite plugin from your local computer and press the Install Now button. +- Click on the Activate button under the "Plugin installed successfully" message. + +If you want to upload the plugin using FTP, [click here](https://themeisle.com/blog/what-is-ftp-wordpress/) to see a detailed explanation about it.