Skip to content

Fetch Environments

Actions
Fetches environments from SFP Server with filtering support
v1.0.0
Latest
Verified creator
Star (0)

Verified

GitHub has manually verified the creator of the action as an official partner organization. For more info see About badges in GitHub Marketplace.

Fetch Environments Action

CI Release

A GitHub Action that fetches environments from SFP Server. Returns environment names as a comma-separated list and JSON array for matrix builds.

Usage

Basic Usage

- name: Fetch Environments
  id: fetch-envs
  uses: flxbl-io/fetch-environments@v1
  with:
    sfp-server-url: ${{ secrets.SFP_SERVER_URL }}
    sfp-server-token: ${{ secrets.SFP_SERVER_TOKEN }}

- name: Use environments
  run: echo "Found environments: ${{ steps.fetch-envs.outputs.allEnvs }}"

With Filtering

- name: Fetch Release Environments
  id: fetch-envs
  uses: flxbl-io/fetch-environments@v1
  with:
    sfp-server-url: ${{ secrets.SFP_SERVER_URL }}
    sfp-server-token: ${{ secrets.SFP_SERVER_TOKEN }}
    filter: 'type:release,metadata:testrun=true'

- name: Deploy to each environment
  run: echo "Deploying to: ${{ steps.fetch-envs.outputs.allEnvs }}"

Matrix Strategy

jobs:
  fetch:
    runs-on: ubuntu-latest
    outputs:
      environments: ${{ steps.fetch-envs.outputs.allEnvsAsJSON }}
    steps:
      - name: Fetch Environments
        id: fetch-envs
        uses: flxbl-io/fetch-environments@v1
        with:
          sfp-server-url: ${{ secrets.SFP_SERVER_URL }}
          sfp-server-token: ${{ secrets.SFP_SERVER_TOKEN }}
          filter: 'type:snapshot'

  deploy:
    needs: fetch
    runs-on: ubuntu-latest
    strategy:
      matrix:
        environment: ${{ fromJSON(needs.fetch.outputs.environments) }}
    steps:
      - name: Deploy to ${{ matrix.environment }}
        run: echo "Deploying to ${{ matrix.environment }}"

Cross-Repository

- name: Fetch Environments from Another Repo
  id: fetch-envs
  uses: flxbl-io/fetch-environments@v1
  with:
    sfp-server-url: ${{ secrets.SFP_SERVER_URL }}
    sfp-server-token: ${{ secrets.SFP_SERVER_TOKEN }}
    repository: 'my-org/another-repo'
    filter: 'type:development'

Inputs

Input Description Required Default
sfp-server-url URL to the SFP Server instance (e.g., https://sfp.example.com) Yes -
sfp-server-token Token for SFP Server authentication Yes -
repository Repository identifier (owner/repo format) No Current repository
filter Filter string for environment selection (see Filter Syntax below) No ''

Outputs

Output Description
allEnvs Comma-separated list of environment names
allEnvsAsJSON JSON array of environment names for matrix builds
count Number of environments found

Filter Syntax

Filters use a key:value format, with multiple filters separated by commas:

Filter Description Example
type Filter by environment category type:release
branch Filter by associated branch branch:develop
metadata Filter by metadata key-value pairs metadata:testrun=true

Examples

# Find all snapshot environments for main branch
filter: 'type:snapshot,branch:main'

# Find all release environments
filter: 'type:release'

# Find environments with specific metadata
filter: 'type:review,metadata:testrun=true'

How It Works

  1. Authentication: Uses SFP Server credentials to authenticate via the sfp CLI.

  2. Fetching: Calls sfp server environment list CLI command with the specified filters.

  3. Output: Generates both comma-separated and JSON array outputs for flexible consumption.

  4. Environment Info File: Writes an envInfos.json file to the workspace with detailed environment information.

Environment Info File

The action writes an envInfos.json file to the workspace containing detailed environment information:

[
  {
    "name": "dev",
    "type": "development",
    "branch": "main",
    "sbx_name": "dev"
  },
  {
    "name": "qa",
    "type": "snapshot",
    "branch": "main",
    "sbx_name": "qa",
    "testrun": "true"
  }
]

Prerequisites

  • SFP Server instance running
  • Repository registered in SFP Server
  • Application token from SFP Server
  • sfp CLI available in the runner (use sfops Docker images)

Development

Prerequisites

  • Node.js 20+
  • npm

Setup

npm install

Build

npm run build

Test

npm test
npm run test:coverage

Lint & Format

npm run lint
npm run format

License

Copyright 2025 flxbl-io. All rights reserved. See LICENSE for details.

Support

Fetch Environments is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Fetches environments from SFP Server with filtering support
v1.0.0
Latest

Verified

GitHub has manually verified the creator of the action as an official partner organization. For more info see About badges in GitHub Marketplace.

Fetch Environments is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.