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
108 changes: 45 additions & 63 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write # Required to push commits back to main
contents: write # Required to push historical snapshot to main
steps:
- uses: actions/checkout@v5
with:
Expand All @@ -27,83 +27,43 @@ jobs:
- name: Validate token list
run: npm run validate

- name: Update timestamp
- name: Create dist directory with timestamped copies
run: |
# Update timestamp to current UTC time
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
jq --arg ts "$TIMESTAMP" '.timestamp = $ts' tokens/token-list.json > tokens/token-list.json.tmp
mv tokens/token-list.json.tmp tokens/token-list.json

# Commit timestamp update if changed (skip husky hooks in CI)
if ! git diff --quiet tokens/token-list.json; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add tokens/token-list.json
HUSKY=0 git commit -m "chore: Update timestamp for release [skip ci]"
git push origin main
fi
mkdir -p dist

- name: Preserve current version as historical snapshot
run: |
# Get the current version being deployed
CURRENT_VERSION=$(jq -r '"\(.version.major).\(.version.minor).\(.version.patch)"' tokens/token-list.json)

# Check if this version already exists in versions/
if [ ! -f "versions/v${CURRENT_VERSION}.json" ]; then
mkdir -p versions
cp tokens/token-list.json versions/v${CURRENT_VERSION}.json
echo "Preserved v${CURRENT_VERSION}.json as historical snapshot"

# Commit the historical snapshot back to main (skip husky hooks in CI)
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add versions/v${CURRENT_VERSION}.json
HUSKY=0 git commit -m "chore: Preserve v${CURRENT_VERSION}.json as historical snapshot [skip ci]"
git push origin main
else
echo "v${CURRENT_VERSION}.json already exists in versions/ directory"
fi
# Get current timestamp
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")

- name: Create dist directory
run: |
mkdir -p dist

# Extract version components
# Extract version components from source file
VERSION=$(jq -r '"\(.version.major).\(.version.minor).\(.version.patch)"' tokens/token-list.json)
MAJOR=$(jq -r '.version.major' tokens/token-list.json)
MINOR=$(jq -r '.version.minor' tokens/token-list.json)

# Copy current version with full version (e.g., v1.1.0.json)
cp tokens/token-list.json dist/v${VERSION}.json

# Copy with major.minor version (e.g., v1.1.json) - updates automatically
cp tokens/token-list.json dist/v${MAJOR}.${MINOR}.json

# Copy with major version only (e.g., v1.json) - updates automatically
cp tokens/token-list.json dist/v${MAJOR}.json

# Copy as latest (always points to newest)
cp tokens/token-list.json dist/latest.json

# Copy base file
cp tokens/token-list.json dist/token-list.json


# Create timestamped version for deployment (source file unchanged)
jq --arg ts "$TIMESTAMP" '.timestamp = $ts' tokens/token-list.json > dist/token-list.json

# Copy timestamped version to all version aliases
cp dist/token-list.json dist/v${VERSION}.json
cp dist/token-list.json dist/v${MAJOR}.${MINOR}.json
cp dist/token-list.json dist/v${MAJOR}.json
cp dist/token-list.json dist/latest.json

# Copy all historical versions and create major.minor and major aliases
if [ -d "versions" ]; then
# Declare associative arrays to track highest versions
declare -A highest_patch # tracks highest patch for each major.minor
declare -A highest_minor # tracks highest minor.patch for each major

for version_file in versions/*.json; do
if [ -f "$version_file" ]; then
# Copy the full version file (e.g., v1.2.0.json)
cp "$version_file" dist/

# Extract version components from the file content
FILE_MAJOR=$(jq -r '.version.major' "$version_file")
FILE_MINOR=$(jq -r '.version.minor' "$version_file")
FILE_PATCH=$(jq -r '.version.patch' "$version_file")

# Skip if this is the current version's major (already created above)
if [ "$FILE_MAJOR" = "$MAJOR" ]; then
echo "Skipping major alias v${FILE_MAJOR}.json - current version takes precedence"
Expand All @@ -113,7 +73,7 @@ jobs:
continue
fi
fi

# Create/update major.minor alias (e.g., v1.2.json)
MINOR_KEY="${FILE_MAJOR}.${FILE_MINOR}"
MINOR_ALIAS="v${MINOR_KEY}.json"
Expand All @@ -123,7 +83,7 @@ jobs:
highest_patch[$MINOR_KEY]=$FILE_PATCH
echo "Created/updated alias ${MINOR_ALIAS} from $(basename $version_file)"
fi

# Create/update major alias (e.g., v1.json) - only for non-current majors
if [ "$FILE_MAJOR" != "$MAJOR" ]; then
MAJOR_ALIAS="v${FILE_MAJOR}.json"
Expand All @@ -141,7 +101,7 @@ jobs:
done
echo "Copied historical versions and created aliases"
fi

# Create index.html that redirects to latest.json
cat > dist/index.html << 'EOF'
<!DOCTYPE html>
Expand All @@ -156,9 +116,31 @@ jobs:
</body>
</html>
EOF

echo "Created versioned files: v${VERSION}.json, v${MAJOR}.${MINOR}.json, v${MAJOR}.json, latest.json"

- name: Preserve current version as historical snapshot
run: |
# Get the current version being deployed
CURRENT_VERSION=$(jq -r '"\(.version.major).\(.version.minor).\(.version.patch)"' tokens/token-list.json)

# Check if this version already exists in versions/
if [ ! -f "versions/v${CURRENT_VERSION}.json" ]; then
mkdir -p versions
# Use the timestamped version from dist/ for the historical snapshot
cp dist/v${CURRENT_VERSION}.json versions/v${CURRENT_VERSION}.json
echo "Preserved v${CURRENT_VERSION}.json as historical snapshot"

# Commit the historical snapshot back to main
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add versions/v${CURRENT_VERSION}.json
HUSKY=0 git commit -m "chore: Preserve v${CURRENT_VERSION}.json as historical snapshot [skip ci]"
git push origin main
else
echo "v${CURRENT_VERSION}.json already exists in versions/ directory"
fi

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ name: PR Validation
on:
pull_request:
branches: [main]
paths:
- "tokens/**"
- "src/**"
- "tests/**"
- "package.json"
- "package-lock.json"

jobs:
validate:
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ This project is licensed under the MIT License - see the [LICENSE](./LICENSE) fi

Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

## Repository Maintenance

### Branch Protection

This repository has special branch protection settings to support automated deployments:

- **PR requirement**: All changes require a pull request with 1 approving review
- **Required status check**: `validate` must pass
- **GitHub Actions bypass**: The `github-actions` app can push directly to `main` to update timestamps and create version snapshots during deployment

This configuration is necessary because the deployment workflow (`deploy.yml`) pushes automated commits to `main` when a release is published:
1. Updates the `timestamp` field in `tokens/token-list.json`
2. Creates a historical snapshot in `versions/`

If org-wide branch protection automation is applied, this repository may need to be excluded to preserve this functionality.

## Security

For security concerns, please submit an issue or contact the Request Network team.
2 changes: 1 addition & 1 deletion tokens/token-list.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Request Network Token List",
"timestamp": "2026-01-22T18:53:30.000Z",
"timestamp": "Set automatically during deployment",
"version": {
"major": 1,
"minor": 4,
Expand Down