Operations 11 min read

How to Quickly Set Up CI/CD for Serverless Projects with GitHub Actions and Jenkins

This guide explains why CI/CD is essential for modern development, outlines its key benefits, and provides step‑by‑step instructions for automating Serverless deployments using GitHub Actions, Jenkinsfile, and related tooling, including code samples and secret configuration.

Tencent Cloud Developer
Tencent Cloud Developer
Tencent Cloud Developer
How to Quickly Set Up CI/CD for Serverless Projects with GitHub Actions and Jenkins

Introduction

With Agile and DevOps becoming mainstream, CI/CD has become a must‑have practice for developers, aiming to deliver reliable software to users faster and with shorter cycles.

Benefits of CI/CD

Shorten release cycles

Reduce risk

Improve code quality

Enable faster feedback loops

Visualize the deployment process

Automating Serverless Projects

Given the growing popularity of Serverless, the article focuses on how to quickly set up CI/CD pipelines for Serverless applications.

GitHub Actions‑Based Deployment

Prerequisites

Your Serverless project code is hosted on GitHub.

The repository contains a serverless.yml file required by the Serverless Framework.

For web functions, ensure the repository root includes an scf_bootstrap file (see the official documentation).

Steps

Search for "tencent serverless" in the GitHub Marketplace and add the tencent-serverless-action (https://github.com/marketplace/actions/tencent-serverless-action).

In the Actions tab, choose “Set up a workflow yourself”.

If you are familiar with Actions, you can use the following single step to install the Serverless Framework and run the deployment command:

- name: serverless scf deploy
  uses: woodyyan/tencent-serverless-action@main

If you need language‑specific configurations, use the examples below.

Python Project Example

# Trigger on pushes to the main branch
name: deploy serverless scf
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: clone local repository
        uses: actions/checkout@v2
      - name: deploy serverless
        uses: woodyyan/tencent-serverless-action@main
        env:
          STAGE: dev
          SERVERLESS_PLATFORM_VENDOR: tencent
          TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
          TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}

Java Project Example

name: deploy serverless scf
on:
  push:
    branches:
      - main
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v2
      - name: Set up JDK 11
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'temurin'
      - name: Build with Gradle
        uses: gradle/gradle-build-action@v2
        with:
          arguments: build
      - name: Create zip folder (Java web function only)
        run: mkdir zip
      - name: Move jar and scf_bootstrap to zip folder
        run: cp ./build/libs/XXX.jar ./scf_bootstrap ./zip
      - name: deploy serverless
        uses: woodyyan/tencent-serverless-action@main
        env:
          STAGE: dev
          SERVERLESS_PLATFORM_VENDOR: tencent
          TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
          TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}

NodeJS Project Example

name: deploy serverless scf
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: install dependencies
        run: npm install
      - name: build
        run: npm run build
      - name: deploy serverless
        uses: woodyyan/tencent-serverless-action@main
        env:
          STAGE: dev
          SERVERLESS_PLATFORM_VENDOR: tencent
          TENCENT_SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
          TENCENT_SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}

Configure Secrets

After the pipeline is set up, add TENCENT_SECRET_ID and TENCENT_SECRET_KEY as repository secrets (Settings → Secrets). These values can be obtained from the Tencent Cloud Access Management console.

Jenkinsfile‑Based Deployment

Prerequisites

The Serverless project is hosted on a Git platform supported by Jenkins (GitHub, GitLab, Gitee, Coding, etc.).

The repository includes a valid serverless.yml file.

Web functions must contain an scf_bootstrap file in the root directory.

Steps

Use the following Jenkinsfile, which works for Python, Java, and NodeJS projects. Adjust the comments as needed.

pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
          userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
      }
    }
    stage('Package') { // Java only
      steps {
        container('maven') {
          echo 'Package start'
          sh "mvn package" // Maven
          sh "./gradlew build" // Gradle
          sh "mkdir zip"
          sh "cp ./build/libs/XXX.jar ./scf_bootstrap ./zip"
        }
      }
    }
    stage('Install Dependencies') {
      steps {
        echo 'Installing dependencies...'
        sh 'npm i -g serverless'
        sh 'npm install' // NodeJS
        echo 'Dependencies installed.'
      }
    }
    stage('Deploy') {
      steps {
        echo 'Deploying...'
        withCredentials([cloudApi(credentialsId: "${env.TENCENT_CLOUD_API_CRED}",
          secretIdVariable: 'TENCENT_SECRET_ID',
          secretKeyVariable: 'TENCENT_SECRET_KEY')]) {
          sh 'echo "TENCENT_SECRET_ID=${TENCENT_SECRET_ID}
TENCENT_SECRET_KEY=${TENCENT_SECRET_KEY}" > .env'
          sh 'sls deploy --debug'
          sh 'rm .env'
        }
        echo 'Deployment completed.'
      }
    }
  }
}

After adding the Jenkinsfile, configure the same TENCENT_SECRET_ID and TENCENT_SECRET_KEY variables in the Jenkins credentials store.

Conclusion

Mastering rapid CI/CD configuration for Serverless applications is a core skill for developers seeking higher efficiency. The provided GitHub Actions and Jenkinsfile examples reduce learning cost and enable developers to focus on core business logic. Future articles will explore additional Serverless DevOps practices.

CI/CD Overview
CI/CD Overview
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Serverlessci/cdAutomationDevOpsJenkinsGitHub Actions
Tencent Cloud Developer
Written by

Tencent Cloud Developer

Official Tencent Cloud community account that brings together developers, shares practical tech insights, and fosters an influential tech exchange community.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.