diff --git a/.github/actions/get-environments.mjs b/.github/actions/get-environments.mjs new file mode 100644 index 0000000..20a09a7 --- /dev/null +++ b/.github/actions/get-environments.mjs @@ -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) diff --git a/.github/workflows/deploy_multiple.yml b/.github/workflows/deploy_multiple.yml index 6387d9f..4b5cd1d 100644 --- a/.github/workflows/deploy_multiple.yml +++ b/.github/workflows/deploy_multiple.yml @@ -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: