Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ jobs:
git checkout dev
git reset --hard origin/dev
git pull
infisical export --env=dev --format=dotenv --path="/web" --projectId=${{ secrets.INFISICAL_PROJECT_ID }} > ./secrets/.env.dev.web

sudo chmod +x ./fetch-web-secrets.sh
# export secrets into .env files
./fetch-web-secrets.sh

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to sudo chmod +x ./fetch-web-secrets.sh before running to give it proper execution permission.


docker compose -f docker-compose.dev.yml pull dev-web
docker compose -f docker-compose.dev.yml up -d --no-deps --force-recreate dev-web

env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
WORKSPACE_SLUG: swamphacks-core
ENVIRONMENT: dev
41 changes: 41 additions & 0 deletions infra/fetch-web-secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail

# Check required environment variables
: "${INFISICAL_CLIENT_ID:?INFISICAL_CLIENT_ID is required}"
: "${INFISICAL_CLIENT_SECRET:?INFISICAL_CLIENT_SECRET is required}"
: "${WORKSPACE_SLUG:=swamphacks-core}"
: "${ENVIRONMENT:=dev}"


# Ensure jq is installed
if ! command -v jq >/dev/null 2>&1; then
sudo apt-get update -y
sudo apt-get install -y jq
fi

# 1) Get access token from Infisical
ACCESS_TOKEN=$(curl -sS --fail -X POST "https://us.infisical.com/api/v1/auth/universal-auth/login" \
-H "Content-Type: application/json" \
-d "{\"clientId\":\"${INFISICAL_CLIENT_ID}\",\"clientSecret\":\"${INFISICAL_CLIENT_SECRET}\"}" \
| jq -r '.accessToken // .data.accessToken')

if [ -z "$ACCESS_TOKEN" ] || [ "$ACCESS_TOKEN" = "null" ]; then
echo "ERROR: Failed to obtain Infisical access token" >&2
exit 1
fi

# 2) Fetch secrets JSON and convert to dotenv
curl -sS --fail -G "https://us.infisical.com/api/v3/secrets/raw" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
--data-urlencode "secretPath=/web" \
--data-urlencode "workspaceSlug=${WORKSPACE_SLUG}" \
--data-urlencode "environment=${ENVIRONMENT}" \
--data-urlencode "viewSecretValue=true" \
| jq -r '.secrets[]?, .imports[].secrets[]? | "\(.secretKey)=\(.secretValue)"' \
> ./secrets/.env.dev.web


# Optional: inspect
echo "✅ .env.dev.web generated"