Cloud development action gives GitHub cloud super capabilities



@ beetcb from the community participated in the code and document contribution of Tencent cloudbase GitHub action V2 (aka cloud development atcion) a few days ago. If you’re rightAutomatically build and deploy cloud development projects using GitHubInterested, welcome to join me to try the V2 cloud development action: tencentcloudbase / cloudbase action

Why care about GitHub actions?

GitHub actions is a CI / CD service launched by GitHub that liberates both hands and automates the development process. For example, when browsing many open source projects, small red crosses and small green checkmarks often appear on the right of GIT commit:
Cloud development action gives GitHub cloud super capabilities

Then this project must use GitHub actions (or other CI / CD services).

This shows that many projects are highly dependent on GitHub actions, which is also highly recognized in the community. Take Tencent cloud development as an example. By introducing cloud development action into the project, it immediately has a more elegant automatic development process:

  • Integration: development, code review, issue, PR, construction and deployment do not need to leave GitHub, making focus normal
  • One click deployment › automatic deployment: users who have used or learned about the cloudbase framework know that one click deployment is a very convenient service. Coupled with cloud development action, every code change(push pr star…) can trigger one click deployment without manual intervention
  • Better protection for private data: once the key is uploaded to GitHub secrets, it is impossible to view the key in plaintext in any form, which is better than the local key.envMuch safer

Limitations of cloud development action v1

I have used V1 version to deploy my blog project, which is very convenient. This is also my first time to start cloud development. With the familiarity with cloud development, it is not difficult to find the limitations of V1 project in Retrospect: it only supports static deployment and lacks maintenance. Maybe Bing (@ binggg) is very busy.

Break the limits and embrace v2

I found the limitations of V1 and tried to find a solution,cloudbase-manager-nodeThis is my first attempt: tencentcloudbase / cloudbase manager node

It also supports many other cloud development solutions. Fortunately, the cloudbase framework appeared in my mind in time: tent / cloudbase framework

It is a front and rear integrated deployment tool officially produced by cloud development, and is equipped with rich plug-ins; Using a simple configuration file, combined with cloudbase cli tools, you can deploy with one click.

With cloudbase framework, we can avoid secondary development in action. On the contrary, we can replace it with a more mature deployment scheme

Process of developing V2

The development of GitHub action in V2 is really simple, thanks to the one click deployment capability provided by cloudbase framework. To sum up, there are only three parts to put ~ elephant ~ application into ~ refrigerator ~ cloud development:

npm install -g @cloudbase/cli
tcb login --apiKeyId "$SECRET_ID" --apiKey "$SECRET_KEY"
tcb framework deploy -e "$ENV_ID"

Install → login → deploy,It’s so simple!

Because this process does not contain any code logic, we do not use any programming language to implement these processes; After consideration, we chose the place where these orders can be executed fastest –SHELL, in GitHub document terms, it is acomposite run steps action, after the core functions are realized, the rest is the optimization of experience:

  • Simplification of output: eliminate useless information output during deployment and reduce the output of useless logs
  • Step grouping: we divide the three key steps into three groups, and track and highlight the executing commands to make users more aware of the current status
  • Document Optimization: use a simple cloud function deployment to teach you how to configure (click it below) tencentcloudbase / cloudbase action

Quick start V2

Boring text, which code is interesting? Next, let’s quickly start cloud development action:
Cloud development action gives GitHub cloud super capabilities

This example will demonstrate how to quickly deploy cloud functions to cloudbase (and set the deployed private environment variable as the environment variable of cloud function runtime)

1. First, we need to introduce cloud development action into the project and write the following GitHub action file.github/workflows/main.yml

on: [push]

    runs-on: ubuntu-latest
    name: Tencent Cloudbase Github Action Example
      - name: Checkout
        uses: actions/[email protected]
      - name: Deploy to Tencent CloudBase
        uses: TencentCloudBase/[email protected]
          secretId: ${{secrets.secretId}}
          secretKey: ${{secrets.secretKey}}
          envId: ${{secrets.envId}}

Detailed description of this profile

Suppose we need to set private environment variables (such as applets) during deploymentappidOr access to the databaseaccessToken), please add the following content to the above code:

name: Tencent Cloudbase Github Action Example
+  accessToken: ${{ secrets.accessToken }}

amongenvLoweraccessTokenKey value pairs are environment variables set during deployment, and their functions are the same as those of local variables.envSame file
2. In order to deploy cloud functions using cloud development action V2, we must configure them in the projectcloudbaserc.jsonFile (and introduce the cloud function plug-in and the environment variables we just configured):

  "envId": "{{env.ENV_ID}}",
  "version": "2.0",
  "framework": {
    "name": "gh-actions-test",
    "plugins": {
      "func": {
        "use": "@cloudbase/framework-plugin-function",
        "inputs": {
          "functions": [
              "name": "example",
              "memorySize": 128,
              "timeout": 5,
              "runtime": "Nodejs10.15",
              "handler": "index.main",
              "envVariables": {
                "accessToken": "{{env.accessToken}}"

Detailed description of this profile

3. Set in project settings / secretssecretId, secretKey, envId, accessTokeninformation

Cloud development action gives GitHub cloud super capabilities

4. After the configuration is completed, when the code is submitted to GitHub, the cloud development action V2 will automatically deploy the code in the projectexampleFunction to cloud development, the environment variable of the immediate function will also be set successfully

Welcome contribution

I believe that after reading this article, you will have a clearer understanding of V2 and more confidence to participate in this project. This project follows the all contributors specification. Any form of contribution will be added to the contributor list. Your contribution is welcome

Introduction to cloudbase framework open source project

Cloudbase framework is an open-source cloud pre life and back-end integrated deployment tool for cloud development. It supports mainstream front-end and back-end frameworks. The front-end and back-end are hosted and deployed on the cloud integrated platform, and supports multiple platforms such as applets, web, fluent, back-end services, etc.

GitHub open source address:

Welcome to a star for the cloudbase framework

Cloudbase framework core contributor program

Welcome to participate in the development of cloudbase framework and become our contributors. We will show the works and information of contributors in the cloud development community, and there will be surprise rewards.

You can choose the following contribution methods:

  • Technical contribution:
  • Contribution application:
  • Contribution code, submit pull request
  • Feedback bug and submit issue
  • Deliver technical speeches at technical meetings

The development of cloudbase framework is inseparable from the positive contributions of the community. This is our list of core contributors. Thank you again for your contributions: –

Product introduction

Tencent CloudBase (TCB) is a cloud original integrated development environment and tool platform provided by Tencent cloud. It provides developers with high availability, automatic resilient expansion of the rear end cloud services, including computing, storage, hosting and other serverless capabilities, which can be used for cloud integration development of multiple end applications (small programs, official account, Web application, Flutter client, etc.) It helps developers build and manage back-end services and cloud resources in a unified way, avoiding cumbersome server construction and operation and maintenance in the process of application development. Developers can focus on the implementation of business logic, with lower development threshold and higher efficiency.
Open Cloud Development: anchor=techsite
Product documentation:
Technical documentation:
Technical exchange plus Q group: 601134960
Latest information on WeChat official account [Tencent cloud development]