Skip to content

Commit 1839eb0

Browse files
authored
Merge pull request #30 from Zondax/notifications
Add weekly upstream check workflow
2 parents d4710b1 + 4a5a80b commit 1839eb0

2 files changed

Lines changed: 69 additions & 1 deletion

File tree

.github/workflows/publishLedger.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: "Build and Publish Ledger App Builder Image"
22
on:
33
workflow_dispatch:
4+
workflow_call:
5+
outputs:
6+
ledger_hash:
7+
description: "LedgerHQ/ledger-app-builder HEAD baked into the image"
8+
value: ${{ jobs.publish_ledger.outputs.ledger_hash }}
49
push:
510
paths:
611
- "ledger-app-builder/*"
@@ -9,6 +14,8 @@ on:
914
jobs:
1015
publish_ledger:
1116
runs-on: ubuntu-latest
17+
outputs:
18+
ledger_hash: ${{ steps.hash.outputs.ledgerHash }}
1219
steps:
1320
- name: Checkout
1421
uses: actions/checkout@v4
@@ -38,7 +45,7 @@ jobs:
3845
with:
3946
context: ledger-app-builder
4047
platforms: linux/amd64,linux/arm64
41-
push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' }}
48+
push: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }}
4249
tags: >-
4350
zondax/ledger-app-builder:${{ steps.hash.outputs.hash }},
4451
zondax/ledger-app-builder:latest,
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)