Fetch Environments
ActionsVerified
A GitHub Action that fetches environments from SFP Server. Returns environment names as a comma-separated list and JSON array for matrix builds.
- 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 }}"- 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 }}"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 }}"- 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'| 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 | '' |
| Output | Description |
|---|---|
allEnvs |
Comma-separated list of environment names |
allEnvsAsJSON |
JSON array of environment names for matrix builds |
count |
Number of environments found |
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 |
# 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'-
Authentication: Uses SFP Server credentials to authenticate via the
sfpCLI. -
Fetching: Calls
sfp server environment listCLI command with the specified filters. -
Output: Generates both comma-separated and JSON array outputs for flexible consumption.
-
Environment Info File: Writes an
envInfos.jsonfile to the workspace with detailed environment information.
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"
}
]- SFP Server instance running
- Repository registered in SFP Server
- Application token from SFP Server
sfpCLI available in the runner (use sfops Docker images)
- Node.js 20+
- npm
npm installnpm run buildnpm test
npm run test:coveragenpm run lint
npm run formatCopyright 2025 flxbl-io. All rights reserved. See LICENSE for details.
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.