···
11
-
- uses: actions/checkout@v3
11
+
- name: Checkout repository
12
+
uses: actions/checkout@v3
uses: oven-sh/setup-bun@v1
···
- name: Replace bangs.json
mv bangs.json src/bangs/bangs.json
39
-
- name: Commit changes
42
+
- name: Configure Git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
47
+
- name: Check for changes and commit
git add src/bangs/bangs.json src/bangs/hashbang.ts
45
-
# Check if the last commit was a bangs update
46
-
LAST_COMMIT_MSG=$(git log -1 --pretty=%B)
47
-
if [[ "$LAST_COMMIT_MSG" == "chore: update bangs.json" ]]; then
48
-
# If it was, amend the commit
49
-
git commit --amend -m "chore: update bangs.json" || exit 0
52
+
# Check if there are changes to commit
53
+
if git diff --staged --quiet; then
54
+
echo "No changes to commit"
55
+
echo "has_changes=false" >> $GITHUB_OUTPUT
59
+
echo "Changes detected in bangs files"
60
+
echo "has_changes=true" >> $GITHUB_OUTPUT
62
+
# Look for bangs update commits in history
63
+
git fetch origin main --unshallow
65
+
# Check if previous commit was a bangs update
66
+
PREV_COMMIT_MSG=$(git log -1 --pretty=%B)
67
+
if [[ "$PREV_COMMIT_MSG" == "chore: update bangs.json" ]]; then
68
+
# Amend the previous commit
69
+
git commit --amend -m "chore: update bangs.json"
71
+
# Create a new commit
72
+
git commit -m "chore: update bangs.json"
75
+
# Push to main - using force only if we amended
76
+
if [[ "$PREV_COMMIT_MSG" == "chore: update bangs.json" ]]; then
77
+
git push --force-with-lease origin main
51
-
# Otherwise, create a new commit
52
-
git commit -m "chore: update bangs.json" || exit 0
79
+
git push origin main
55
-
git push --force-with-lease
82
+
# Handle Tangled push only if we have new changes
83
+
- name: Setup Tailscale
84
+
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 }}
65
-
run: git remote add tangled git@ember:did:plc:krxbvxvis5skq7jj6eot23ul/unduckified
67
-
- name: Configure ssh
91
+
- name: Configure SSH
92
+
if: steps.check_changes.outputs.has_changes == 'true'
echo "StrictHostKeyChecking no" >> ~/.ssh/config
72
-
- name: Push to tangled
73
-
run: git push tangled main
97
+
- name: Push to Tangled
98
+
if: steps.check_changes.outputs.has_changes == 'true'
100
+
git remote add tangled git@ember:did:plc:krxbvxvis5skq7jj6eot23ul/unduckified || true
101
+
git push tangled main
102
+
continue-on-error: true