Skip to content

Commit 2c7f021

Browse files
committed
feature: Add preprod,preview to CI workflow
Add network-specific environment variables to fetch-params script
1 parent 1dd7a7e commit 2c7f021

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

.github/workflows/update-params.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ on:
44
push: {}
55

66
env:
7-
BLOCKFROST_PROJECT_ID: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
7+
BLOCKFROST_PROJECT_ID_MAINNET: ${{ secrets.BLOCKFROST_PROJECT_ID_MAINNET }}
8+
BLOCKFROST_PROJECT_ID_PREPROD: ${{ secrets.BLOCKFROST_PROJECT_ID_PREPROD }}
9+
BLOCKFROST_PROJECT_ID_PREVIEW: ${{ secrets.BLOCKFROST_PROJECT_ID_PREVIEW }}
810

911
jobs:
1012
update_parameters:
1113
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
network:
18+
- mainnet
19+
- preprod
20+
- preview
21+
1222
steps:
1323
- name: Git checkout
1424
uses: actions/checkout@v4
1525

1626
- name: Update parameters
17-
run: ./fetch-params.sh mainnet
27+
run: ./fetch-params.sh "${{ matrix.network }}"
1828

1929
- name: Commit updated files
2030
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)