|
| 1 | +name: "Weekly Upstream Check" |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 9 * * 1" # every Monday at 09:00 UTC |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + check: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + needs_build: ${{ steps.check.outputs.needs_build }} |
| 16 | + upstream_hash: ${{ steps.upstream.outputs.hash }} |
| 17 | + steps: |
| 18 | + - name: Get upstream HEAD hash |
| 19 | + id: upstream |
| 20 | + run: | |
| 21 | + HASH=$(git ls-remote https://github.com/LedgerHQ/ledger-app-builder | head -n 1 | awk '{print $1}') |
| 22 | + echo "hash=$HASH" >> $GITHUB_OUTPUT |
| 23 | + echo "Upstream HEAD: $HASH" |
| 24 | +
|
| 25 | + - name: Check if image tag already exists on Docker Hub |
| 26 | + id: check |
| 27 | + run: | |
| 28 | + TAG="ledger-${{ steps.upstream.outputs.hash }}" |
| 29 | + if curl -sfL "https://hub.docker.com/v2/repositories/zondax/ledger-app-builder/tags/${TAG}" > /dev/null; then |
| 30 | + echo "needs_build=false" >> $GITHUB_OUTPUT |
| 31 | + echo "Tag ${TAG} already published — nothing to do." |
| 32 | + else |
| 33 | + echo "needs_build=true" >> $GITHUB_OUTPUT |
| 34 | + echo "Tag ${TAG} missing — will rebuild." |
| 35 | + fi |
| 36 | +
|
| 37 | + build: |
| 38 | + needs: check |
| 39 | + if: needs.check.outputs.needs_build == 'true' |
| 40 | + uses: ./.github/workflows/publishLedger.yml |
| 41 | + secrets: inherit |
| 42 | + |
| 43 | + notify: |
| 44 | + needs: [check, build] |
| 45 | + if: needs.check.outputs.needs_build == 'true' && success() |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - name: Post Slack notification |
| 49 | + env: |
| 50 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 51 | + UPSTREAM_HASH: ${{ needs.check.outputs.upstream_hash }} |
| 52 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 53 | + run: | |
| 54 | + SHORT="${UPSTREAM_HASH:0:7}" |
| 55 | + jq -n \ |
| 56 | + --arg hash "$UPSTREAM_HASH" \ |
| 57 | + --arg short "$SHORT" \ |
| 58 | + --arg run "$RUN_URL" \ |
| 59 | + '{text: "*Ledger app-builder updated:* <https://github.com/LedgerHQ/ledger-app-builder/commit/\($hash)|`\($short)`> A fresh `zondax/ledger-app-builder:ledger-\($hash)` has been pushed. Bump the image hash in zxlib to pick up the new SDK. <\($run)|Workflow run>"}' \ |
| 60 | + | curl -sSf -X POST -H 'Content-Type: application/json' \ |
| 61 | + --data @- "$SLACK_WEBHOOK_URL" |
0 commit comments