61 lines
2.0 KiB
Markdown
61 lines
2.0 KiB
Markdown
# Litten
|
|
|
|
* n8n - [cli commands](https://docs.n8n.io/hosting/cli-commands/#credentials)
|
|
|
|
## Caddy with namecheap-dns
|
|
|
|
Some special handling is necessary for Caddy
|
|
|
|
```sh
|
|
#!/usr/bin/env bash
|
|
# This script demonstrates how to construct a Go pseudo-version for a commit from the
|
|
# "caddy-dns/namecheap" repository using curl, jq, and date.
|
|
#
|
|
# The pseudoversion format is:
|
|
# 0.0.0-YYYYMMDDHHMMSS-<short-commit-hash>
|
|
#
|
|
# Steps:
|
|
#
|
|
# 1. Query the GitHub API for the commit metadata. (The URL is:
|
|
# https://api.github.com/repos/caddy-dns/namecheap/commits/HEAD
|
|
# You can replace HEAD with a specific commit SHA if needed.)
|
|
#
|
|
# 2. Extract the commit date. The GitHub API returns the date in ISO 8601 format, e.g.,
|
|
# "2025-02-15T18:47:56Z".
|
|
#
|
|
# 3. Convert that date to UTC timestamp in the format YYYYMMDDHHMMSS.
|
|
#
|
|
# 4. Extract the full commit SHA and take its first 12 characters.
|
|
#
|
|
# 5. Combine these values in the form: "0.0.0-<timestamp>-<short-hash>", resulting in a pseudo-version,
|
|
# like: "0.0.0-20250215184756-635a4c34fd25"
|
|
#
|
|
# Example:
|
|
# Given:
|
|
# Commit date = "2025-02-15T18:47:56Z"
|
|
# Commit SHA = "635a4c34fd25d48df62f8e9d5485ac9026796a83"
|
|
# The pseudo-version will be:
|
|
# 0.0.0-20250215184756-635a4c34fd25
|
|
|
|
# Set the commit reference (or use a specific commit SHA instead of "HEAD")
|
|
COMMIT_REF="HEAD"
|
|
|
|
# Fetch commit metadata from GitHub API
|
|
COMMIT_JSON=$(curl -s "https://api.github.com/repos/caddy-dns/namecheap/commits/$COMMIT_REF")
|
|
|
|
# Extract the commit date (author date)
|
|
COMMIT_DATE=$(echo "$COMMIT_JSON" | jq -r '.commit.author.date')
|
|
|
|
# Convert the date to UTC (should already be in UTC if it ends with 'Z') and format it as YYYYMMDDHHMMSS
|
|
TIMESTAMP=$(date -u -d "$COMMIT_DATE" +"%Y%m%d%H%M%S")
|
|
|
|
# Extract the full commit hash and get the first 12 characters
|
|
FULL_HASH=$(echo "$COMMIT_JSON" | jq -r '.sha')
|
|
SHORT_HASH=${FULL_HASH:0:12}
|
|
|
|
# Construct the pseudo-version string
|
|
PSEUDO_VERSION="0.0.0-${TIMESTAMP}-${SHORT_HASH}"
|
|
|
|
echo "Pseudo-Version: $PSEUDO_VERSION"
|
|
```
|