Skip to content

localopsco/deploy-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalOps Deploy Action

CI Coverage

GitHub Action to trigger deployments in LocalOps Deliver.

Quick Start

- name: Trigger LocalOps Deployment
  uses: localopsco/deploy-action@v0
  with:
    api_token: ${{ secrets.LOCALOPS_API_TOKEN }}
    environment_id: 'env-123'
    service_id: 'svc-456'
    commit_id: ${{ github.sha }}

Inputs

Input Description Required Default
api_token LocalOps API token
environment_id Target environment ID
service_id Target service ID
commit_id Git commit SHA to deploy
docker_image_tag Docker image tag to deploy
helm_chart_version Helm chart version to deploy
preview Create a preview deployment
base_url LocalOps API base URL https://sdk.localops.co

Note: Exactly one of commit_id, docker_image_tag, or helm_chart_version must be provided (marked with ⚡).

Preview: When preview is set to true, commit_id is required. Docker image and Helm chart based preview deployments are not yet supported.

Examples

Deploy on Push to Main

Automatically deploy when changes are pushed to the main branch:

name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Trigger LocalOps Deployment
        uses: localopsco/deploy-action@v0
        with:
          api_token: ${{ secrets.LOCALOPS_API_TOKEN }}
          environment_id: ${{ vars.ENVIRONMENT_ID }}
          service_id: ${{ vars.SERVICE_ID }}
          commit_id: ${{ github.sha }}

Build and Deploy Docker Image

Build a Docker image, push to a registry, and deploy:

name: Build and Deploy

on:
  push:
    branches: [main]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}

      - name: Build and Push
        uses: docker/build-push-action@v6
        with:
          context: .
          push: true
          tags: myorg/myapp:${{ github.sha }}

      - name: Trigger LocalOps Deployment
        uses: localopsco/deploy-action@v0
        with:
          api_token: ${{ secrets.LOCALOPS_API_TOKEN }}
          environment_id: ${{ vars.ENVIRONMENT_ID }}
          service_id: ${{ vars.SERVICE_ID }}
          docker_image_tag: ${{ github.sha }}

Deploy Helm Chart

Deploy a specific Helm chart version:

- name: Deploy Helm Chart
  uses: localopsco/deploy-action@v0
  with:
    api_token: ${{ secrets.LOCALOPS_API_TOKEN }}
    environment_id: ${{ vars.ENVIRONMENT_ID }}
    service_id: ${{ vars.SERVICE_ID }}
    helm_chart_version: '1.2.3'

Deploy Preview Environment

Create a preview environment for each pull request. This is only supported in PR workflows and requires commit_id:

name: Preview

on:
  pull_request:
    branches: [main]

jobs:
  preview:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Deploy Preview
        uses: localopsco/deploy-action@v0
        with:
          api_token: ${{ secrets.LOCALOPS_API_TOKEN }}
          environment_id: ${{ vars.ENVIRONMENT_ID }}
          service_id: ${{ vars.SERVICE_ID }}
          commit_id: ${{ github.event.pull_request.head.sha }}
          preview: true

Note: Preview deployments must run in a pull_request workflow. The action automatically picks up the PR number and branch name from the workflow context.

Authentication

For triggering deployments, you will need to provide an API token from your LocalOps account.

Development

# Install dependencies
npm install

# Run tests
npm test

# Build for distribution
npm run package

License

MIT

About

Github Action to deploy service

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Generated from actions/typescript-action