|
| 1 | +name: Check Upstream |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 */6 * * *" # Every 6 hours |
| 6 | + workflow_dispatch: # Allow manual trigger |
| 7 | + |
| 8 | +jobs: |
| 9 | + check: |
| 10 | + name: Check for cute_framework updates |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Get latest upstream commit SHA |
| 14 | + id: upstream |
| 15 | + run: | |
| 16 | + SHA=$(curl -s \ |
| 17 | + -H "Accept: application/vnd.github+json" \ |
| 18 | + https://api.github.com/repos/RandyGaul/cute_framework/commits/master \ |
| 19 | + | jq -r '.sha[:7]') |
| 20 | + echo "sha=$SHA" >> "$GITHUB_OUTPUT" |
| 21 | +
|
| 22 | + - name: Restore cached SHA |
| 23 | + id: cache |
| 24 | + uses: actions/cache/restore@v4 |
| 25 | + with: |
| 26 | + path: .upstream-sha |
| 27 | + key: upstream-sha-${{ steps.upstream.outputs.sha }} |
| 28 | + restore-keys: upstream-sha- |
| 29 | + |
| 30 | + - name: Read cached SHA |
| 31 | + id: cached |
| 32 | + run: | |
| 33 | + if [ -f .upstream-sha ]; then |
| 34 | + echo "sha=$(cat .upstream-sha)" >> "$GITHUB_OUTPUT" |
| 35 | + else |
| 36 | + echo "sha=" >> "$GITHUB_OUTPUT" |
| 37 | + fi |
| 38 | +
|
| 39 | + - name: Compare and trigger deploy |
| 40 | + if: steps.upstream.outputs.sha != steps.cached.outputs.sha && steps.upstream.outputs.sha != 'null' |
| 41 | + env: |
| 42 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + run: | |
| 44 | + echo "Upstream changed: ${{ steps.cached.outputs.sha }} -> ${{ steps.upstream.outputs.sha }}" |
| 45 | + gh workflow run fly-deploy.yml --repo ${{ github.repository }} |
| 46 | +
|
| 47 | + - name: Save new SHA to cache |
| 48 | + if: steps.upstream.outputs.sha != 'null' |
| 49 | + run: echo "${{ steps.upstream.outputs.sha }}" > .upstream-sha |
| 50 | + |
| 51 | + - name: Update cache |
| 52 | + if: steps.upstream.outputs.sha != steps.cached.outputs.sha && steps.upstream.outputs.sha != 'null' |
| 53 | + uses: actions/cache/save@v4 |
| 54 | + with: |
| 55 | + path: .upstream-sha |
| 56 | + key: upstream-sha-${{ steps.upstream.outputs.sha }} |
0 commit comments