A fast, local-first "redirection engine" for !bang users with a few extra features ^-^

feat: hopefully avoid repo squashing

dunkirk.sh 3b1e4106 5acf9235

verified
Changed files
+49 -20
.github
workflows
+49 -20
.github/workflows/update-bangs.yaml
···
fetch-bangs:
runs-on: ubuntu-latest
steps:
-
- uses: actions/checkout@v3
+
- name: Checkout repository
+
uses: actions/checkout@v3
+
with:
+
fetch-depth: 1
- name: Install bun
uses: oven-sh/setup-bun@v1
···
- name: Replace bangs.json
run: |
-
mkdir -p src
+
mkdir -p src/bangs
mv bangs.json src/bangs/bangs.json
- name: 🥔 hash
run: bun run hash
-
- name: Commit changes
+
- name: Configure Git
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
+
+
- name: Check for changes and commit
+
id: check_changes
+
run: |
git add src/bangs/bangs.json src/bangs/hashbang.ts
-
-
# Check if the last commit was a bangs update
-
LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
-
if [[ "$LAST_COMMIT_MSG" == "chore: update bangs.json" ]]; then
-
# If it was, amend the commit
-
git commit --amend -m "chore: update bangs.json" || exit 0
+
+
# Check if there are changes to commit
+
if git diff --staged --quiet; then
+
echo "No changes to commit"
+
echo "has_changes=false" >> $GITHUB_OUTPUT
+
exit 0
+
fi
+
+
echo "Changes detected in bangs files"
+
echo "has_changes=true" >> $GITHUB_OUTPUT
+
+
# Look for bangs update commits in history
+
git fetch origin main --unshallow
+
+
# Check if previous commit was a bangs update
+
PREV_COMMIT_MSG=$(git log -1 --pretty=%B)
+
if [[ "$PREV_COMMIT_MSG" == "chore: update bangs.json" ]]; then
+
# Amend the previous commit
+
git commit --amend -m "chore: update bangs.json"
+
else
+
# Create a new commit
+
git commit -m "chore: update bangs.json"
+
fi
+
+
# Push to main - using force only if we amended
+
if [[ "$PREV_COMMIT_MSG" == "chore: update bangs.json" ]]; then
+
git push --force-with-lease origin main
else
-
# Otherwise, create a new commit
-
git commit -m "chore: update bangs.json" || exit 0
+
git push origin main
fi
-
git push --force-with-lease
-
-
- name: Tailscale
+
# Handle Tangled push only if we have new changes
+
- name: Setup Tailscale
+
if: steps.check_changes.outputs.has_changes == 'true'
uses: tailscale/github-action@v3
with:
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
tags: tag:ci
-
- name: Add remote
-
run: git remote add tangled git@ember:did:plc:krxbvxvis5skq7jj6eot23ul/unduckified
-
-
- name: Configure ssh
+
- name: Configure SSH
+
if: steps.check_changes.outputs.has_changes == 'true'
run: |
mkdir -p ~/.ssh
echo "StrictHostKeyChecking no" >> ~/.ssh/config
-
- name: Push to tangled
-
run: git push tangled main
+
- name: Push to Tangled
+
if: steps.check_changes.outputs.has_changes == 'true'
+
run: |
+
git remote add tangled git@ember:did:plc:krxbvxvis5skq7jj6eot23ul/unduckified || true
+
git push tangled main
+
continue-on-error: true