···
+
- name: Checkout repository
+
uses: actions/checkout@v3
uses: oven-sh/setup-bun@v1
···
- name: Replace bangs.json
mv bangs.json src/bangs/bangs.json
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
git add src/bangs/bangs.json src/bangs/hashbang.ts
+
# Check if there are changes to commit
+
if git diff --staged --quiet; then
+
echo "No changes to commit"
+
echo "has_changes=false" >> $GITHUB_OUTPUT
+
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"
+
git commit -m "chore: update bangs.json"
+
# 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
+
# 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
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
+
if: steps.check_changes.outputs.has_changes == 'true'
echo "StrictHostKeyChecking no" >> ~/.ssh/config
+
- name: Push to Tangled
+
if: steps.check_changes.outputs.has_changes == 'true'
+
git remote add tangled git@ember:did:plc:krxbvxvis5skq7jj6eot23ul/unduckified || true
+
continue-on-error: true