Skip to content

Commit

Permalink
Get environments from GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
ksenia-vazhdaeva committed Jan 20, 2025
1 parent bc1ffea commit 23c3fa9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/actions/get-environments.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Octokit } from "@octokit/action";

const octokit = new Octokit();
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");

const data = await octokit.paginate("GET /repos/{owner}/{repo}/environments", {
owner,
repo,
per_page: 100,
// headers: {
// "X-GitHub-Api-Version": "2022-11-28",
// },
});
const environments = data.map(e => e.name)

console.log(environments)
16 changes: 16 additions & 0 deletions .github/workflows/deploy_multiple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ on:
workflow_dispatch:

jobs:
get-environments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install @octokit/action
- run: |
DATA=$(node .github/actions/get-environments.mjs)
echo $DATA
echo exporting
echo "data=$DATA" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
build:
runs-on: ubuntu-latest
strategy:
Expand Down

0 comments on commit 23c3fa9

Please sign in to comment.