Automated Deployment

Last updated: 2020-10-16 10:36:30


    During serverless application development, you need to run the deployment command manually to deploy the developed project into the cloud. You can introduce certain CI capabilities to automatically deploy a serverless application.

    Automated Deployment Based on GitHub


    • You have created a serverless application. You can create a serverless project and the required environments and branches as instructed in Developing Project.
    • You have hosted your serverless project onto GitHub.


    During development and testing, to facilitate development, testing, and debugging, you can implement automated deployment of the code after it is submitted in the following steps:

    1. Select the target branch for automated deployment (in this example, the dev branch is selected).
    2. Create your action under this branch as instructed in Configuring a workflow.


      GitHub stipulates that if an event occurs on a certain repository branch, the workflow file must exist in the repository of the branch.

    3. Configure the Tencent Cloud key as instructed in Using variables and secrets in a workflow.
    4. Configure the action for deployment.
    # When the code is pushed to the `dev` branch, the current workflow will be executed
    # For more information on configuration, please visit
    name: deploy serverless
    on: # Configuration of the event and branch listened on
          - dev 
      test: # Configure unit test
        name: test
        runs-on: ubuntu-latest
          - name: unit test
            run: '' 
        name: deploy serverless
        runs-on: ubuntu-latest
        needs: [test]
          - name: clone local repository
            uses: actions/checkout@v2
          - name: install serverless
            run: npm install -g serverless
          - name: install dependency
            run: npm install
          - name: build
            run: npm build
          - name: deploy serverless
            run: sls deploy --debug
            env: # Environment variable
              STAGE: dev # Your deployment environment
              SERVERLESS_PLATFORM_VENDOR: tencent # The serverless platform is `aws` by default outside Mainland China. Here, it is set to `tencent`
              TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }} # `secret ID` of your Tencent Cloud account
              TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}# `secret key` of your Tencent Cloud account

    After the above configuration is completed, every time the code is submitted to the dev branch, it will be automatically deployed.