nice clean recipes pear.dunkirk.sh
recipes
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: remove deploy workflow

-157
-157
.github/workflows/deploy.yml
··· 1 - name: Deploy 2 - 3 - on: 4 - push: 5 - branches: [main] 6 - workflow_dispatch: 7 - 8 - concurrency: 9 - group: deploy 10 - cancel-in-progress: false 11 - 12 - jobs: 13 - deploy: 14 - name: pear → terebithia 15 - runs-on: ubuntu-latest 16 - environment: 17 - name: production 18 - url: https://pear.dunkirk.sh 19 - 20 - steps: 21 - - uses: actions/checkout@v4 22 - 23 - - name: Set up Go 24 - uses: actions/setup-go@v5 25 - with: 26 - go-version-file: go.mod 27 - 28 - - name: Install cross-compiler 29 - run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu 30 - 31 - - name: Install musl cross-compiler 32 - run: | 33 - curl -L https://musl.cc/aarch64-linux-musl-cross.tgz | sudo tar xz -C /opt 34 - echo "/opt/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH 35 - 36 - - name: Build 37 - run: GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=aarch64-linux-musl-gcc go build -ldflags '-linkmode external -extldflags "-static" -X main.gitHash=$(git rev-parse --short HEAD)' -o pear . 38 - 39 - - name: Setup Tailscale 40 - uses: tailscale/github-action@v4 41 - with: 42 - oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} 43 - oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} 44 - tags: tag:ci 45 - use-cache: "true" 46 - 47 - - name: Configure SSH 48 - run: | 49 - mkdir -p ~/.ssh 50 - echo "StrictHostKeyChecking accept-new" >> ~/.ssh/config 51 - 52 - - name: Deploy 53 - id: deploy 54 - run: | 55 - C="\033[36m" G="\033[32m" Y="\033[33m" D="\033[2m" R="\033[0m" 56 - echo "start=$(date +%s)" >> "$GITHUB_OUTPUT" 57 - PREV_SHORT=$(ssh pear@terebithia "cd ~/app && git rev-parse --short HEAD") 58 - PREV_FULL=$(ssh pear@terebithia "cd ~/app && git rev-parse HEAD") 59 - 60 - echo "prev_short=$PREV_SHORT" >> "$GITHUB_OUTPUT" 61 - echo "prev_full=$PREV_FULL" >> "$GITHUB_OUTPUT" 62 - 63 - echo -e "${C}:: pear${R} ${D}${PREV_SHORT}${R}" 64 - 65 - # Snapshot DB before deploy 66 - ssh pear@terebithia "cp /var/lib/pear/data/pear.db /var/lib/pear/data/pear.db.pre-deploy 2>/dev/null || true" 67 - 68 - # Pull latest code 69 - ssh pear@terebithia << 'PULL' 70 - set -e 71 - cd ~/app 72 - git fetch --all --quiet 73 - git reset --hard origin/main --quiet 74 - PULL 75 - 76 - NEW_SHORT=$(ssh pear@terebithia "cd ~/app && git rev-parse --short HEAD") 77 - NEW_FULL=$(ssh pear@terebithia "cd ~/app && git rev-parse HEAD") 78 - echo "new_short=$NEW_SHORT" >> "$GITHUB_OUTPUT" 79 - echo "new_full=$NEW_FULL" >> "$GITHUB_OUTPUT" 80 - 81 - echo -e "${C}:: pear${R} ${D}${PREV_SHORT} → ${NEW_SHORT}${R}" 82 - 83 - # Upload binary and restart 84 - echo "::group::upload & restart" 85 - scp pear pear@terebithia:~/app/pear-new 86 - ssh pear@terebithia << 'INSTALL' 87 - set -e 88 - cd ~/app 89 - cp pear pear-prev 90 - chmod +x pear-new 91 - mv -f pear-new pear 92 - sudo /run/current-system/sw/bin/systemctl restart pear.service 93 - INSTALL 94 - echo "::endgroup::" 95 - 96 - echo -e "${G}:: deployed pear${R}" 97 - 98 - - name: Health check 99 - id: health 100 - run: | 101 - for i in $(seq 1 12); do 102 - if curl -sf -o /dev/null "https://pear.dunkirk.sh"; then 103 - echo "status=healthy" >> "$GITHUB_OUTPUT" 104 - exit 0 105 - fi 106 - echo "Attempt $i/12 failed" 107 - sleep 5 108 - done 109 - echo "status=failed" >> "$GITHUB_OUTPUT" 110 - exit 1 111 - 112 - - name: Summary 113 - if: always() 114 - run: | 115 - DURATION="$(($(date +%s) - ${{ steps.deploy.outputs.start }}))s" 116 - PREV_SHORT="${{ steps.deploy.outputs.prev_short }}" 117 - PREV_FULL="${{ steps.deploy.outputs.prev_full }}" 118 - NEW_SHORT="${{ steps.deploy.outputs.new_short }}" 119 - NEW_FULL="${{ steps.deploy.outputs.new_full }}" 120 - HEALTH="${{ steps.health.outputs.status }}" 121 - REPO="https://github.com/${{ github.repository }}" 122 - 123 - if [ "${{ job.status }}" = "success" ]; then STATUS="Deployed"; else STATUS="Failed"; fi 124 - 125 - cat >> "$GITHUB_STEP_SUMMARY" << EOF 126 - | status | commits | health | 127 - |---|---|---| 128 - | \`${STATUS}\` in \`${DURATION}\` | [\`${PREV_SHORT}\`](${REPO}/commit/${PREV_FULL}) → [\`${NEW_SHORT}\`](${REPO}/commit/${NEW_FULL}) | \`${HEALTH:-skipped}\` | 129 - EOF 130 - 131 - - name: Rollback on failure 132 - if: failure() 133 - run: | 134 - echo "::warning::Deploy failed — rolling back pear" 135 - 136 - ssh pear@terebithia << 'ROLLBACK' 137 - set -e 138 - RED="\033[31m" Y="\033[33m" G="\033[32m" D="\033[2m" R="\033[0m" 139 - cd ~/app 140 - 141 - if [ -f pear-prev ]; then 142 - echo -e "${Y}:: rolling back to previous binary${R}" 143 - sudo /run/current-system/sw/bin/systemctl stop pear.service || true 144 - 145 - if [ -f /var/lib/pear/data/pear.db.pre-deploy ]; then 146 - echo -e "${Y}:: restoring database snapshot${R}" 147 - cp /var/lib/pear/data/pear.db.pre-deploy /var/lib/pear/data/pear.db 148 - fi 149 - 150 - mv -f pear-prev pear 151 - sudo /run/current-system/sw/bin/systemctl restart pear.service 152 - echo -e "${G}:: rolled back to previous binary${R}" 153 - else 154 - echo -e "${RED}:: no previous commit recorded, cannot rollback${R}" 155 - exit 1 156 - fi 157 - ROLLBACK