Skip to content

Commit 1a70e68

Browse files
committed
feature: Add preprod,preview to CI workflow
Add network-specific environment variables to fetch-params script
1 parent 60e3a41 commit 1a70e68

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

.github/workflows/update-params.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,23 @@ on:
77
workflow_dispatch: {}
88

99
env:
10-
BLOCKFROST_PROJECT_ID: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
10+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
11+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ secrets.BLOCKFROST_PROJECT_ID_PREPROD }}
12+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ secrets.BLOCKFROST_PROJECT_ID_PREVIEW }}
1113

1214
jobs:
1315
update_parameters:
1416
runs-on: ubuntu-latest
17+
1518
steps:
1619
- name: Git checkout
1720
uses: actions/checkout@v4
1821

1922
- name: Update parameters
20-
run: ./fetch-params.sh mainnet
23+
run: |
24+
./fetch-params.sh mainnet
25+
./fetch-params.sh preprod
26+
./fetch-params.sh preview
2127
2228
- name: Commit updated files
2329
uses: EndBug/add-and-commit@v9

fetch-params.sh

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ environments:
99
mainnet
1010
preprod
1111
preview
12-
all
1312
1413
Options:
1514
-p, --project-id string Blockfrost API key (overrides BLOCKFROST_PROJECT_ID environment variable)
@@ -18,6 +17,27 @@ Options:
1817
EOF
1918
}
2019

20+
lookup_project_id () {
21+
local env="$(echo ${ENV} | tr '[:lower:]' '[:upper:]')"
22+
local env_key="BLOCKFROST_PROJECT_ID_${env}"
23+
BLOCKFROST_PROJECT_ID_NETWORK="${!env_key}"
24+
25+
if [[ -n "${PROJECT_ID}" ]]; then
26+
echo "${PROJECT_ID}"
27+
elif [[ -n "${BLOCKFROST_PROJECT_ID_NETWORK}" ]]; then
28+
echo "${BLOCKFROST_PROJECT_ID_NETWORK}"
29+
elif [[ -n "${BLOCKFROST_PROJECT_ID}" ]]; then
30+
echo "${BLOCKFROST_PROJECT_ID}"
31+
else
32+
cat << EOF >&2
33+
Missing Blockfrost API key! \
34+
Use the BLOCKFROST_PROJECT_ID/BLOCKFROST_PROJECT_ID_<NETWORK> environment variables or --project-id option to specify it.
35+
EOF
36+
37+
exit 2
38+
fi
39+
}
40+
2141
# Parse command line arguments
2242
if ! OPTS=$(getopt -o p:h --long project-id:,help -n "fetch-cardano-cfg.sh" -- "$@"); then
2343
exit 1
@@ -59,18 +79,7 @@ else
5979
ENV=$1
6080
fi
6181

62-
if [[ -z "${PROJECT_ID}" && -n "${BLOCKFROST_PROJECT_ID}" ]]; then
63-
PROJECT_ID="${BLOCKFROST_PROJECT_ID}"
64-
fi
65-
66-
if [[ -z "${PROJECT_ID}" ]]; then
67-
cat << EOF >&2
68-
Missing Blockfrost API key! \
69-
Use the BLOCKCHAID_PROJECT_ID environment variable or --project-id option to specify it.
70-
EOF
71-
72-
exit 2
73-
fi
82+
PROJECT_ID="$(lookup_project_id)"
7483

7584
# Calculate endpoint
7685
case "${ENV}" in

0 commit comments

Comments
 (0)