Skip to content

Commit ec0300b

Browse files
committed
TF-1302 chore(ci): enable SSH access for private Flutter deps and standardize workflows
1 parent 0031073 commit ec0300b

File tree

8 files changed

+212
-47
lines changed

8 files changed

+212
-47
lines changed

.github/workflows/analyze-test.yaml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,55 @@ jobs:
2929
fail-fast: false
3030

3131
steps:
32+
# 🔄 Checkout repository
3233
- name: Checkout repository
3334
uses: actions/checkout@v4
3435

35-
- name: Setup flutter
36+
# 🧰 Setup SSH (required for private git@ dependencies)
37+
- name: Set up SSH for private Git dependencies
38+
uses: webfactory/[email protected]
39+
with:
40+
ssh-private-key: ${{ secrets.SSH_KEY }}
41+
42+
# ⚙️ Add GitHub to known hosts (avoid "Host key verification failed")
43+
- name: Add GitHub to known hosts
44+
run: |
45+
mkdir -p ~/.ssh
46+
ssh-keyscan github.com >> ~/.ssh/known_hosts
47+
48+
# 🚀 Setup Flutter SDK
49+
- name: Setup Flutter
3650
uses: subosito/flutter-action@v2
3751
with:
3852
flutter-version: ${{ env.FLUTTER_VERSION }}
3953
channel: "stable"
4054
cache: true
4155
cache-key: "deps-${{ hashFiles('**/pubspec.lock') }}"
42-
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
56+
cache-path: ${{ runner.tool_cache }}/flutter
4357

58+
# 🔥 Setup Firebase environment (if required by tests)
4459
- name: Setup Firebase env
4560
env:
4661
FIREBASE_ENV: ${{ secrets.FIREBASE_ENV }}
4762
run: ./scripts/setup-firebase.sh
4863

64+
# 🧱 Prebuild step (runs flutter pub get + build_runner + intl generation)
4965
- name: Run prebuild
5066
run: ./scripts/prebuild.sh
5167

52-
- name: Analyze
68+
# 🧩 Run Flutter static analysis
69+
- name: Analyze Dart code
5370
uses: zgosalvez/github-actions-analyze-dart@v1
5471

55-
- name: Test
72+
# 🧪 Run tests for each module in matrix
73+
- name: Run tests
5674
env:
5775
MODULES: ${{ matrix.modules }}
5876
run: ./scripts/test.sh
5977

78+
# 📤 Upload test reports (always, even on failure)
6079
- name: Upload test reports
61-
if: success() || failure() # Always upload report
80+
if: success() || failure()
6281
uses: actions/upload-artifact@v4
6382
with:
6483
name: test-reports-${{ matrix.modules }}

.github/workflows/build.yaml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,62 +19,88 @@ jobs:
1919
- os: android
2020
runner: ubuntu-latest
2121
- os: ios
22-
runner: macos-14 # Use macos-14 runners because Xcode 16 only exists on macOS 14+.
22+
runner: macos-14 # Xcode 16 is only available on macOS 14+
2323
environment: dev
2424

2525
steps:
26+
# 🧰 Setup SSH (required because some dependencies use git@ URLs)
27+
- name: Set up SSH for private Git dependencies
28+
uses: webfactory/[email protected]
29+
with:
30+
ssh-private-key: ${{ secrets.SSH_KEY }}
31+
32+
# ⚙️ Add GitHub to known hosts to avoid "Host key verification failed"
33+
- name: Add GitHub to known hosts
34+
run: |
35+
mkdir -p ~/.ssh
36+
ssh-keyscan github.com >> ~/.ssh/known_hosts
37+
38+
# 📦 Checkout the repository (uses HTTPS by default, SSH key not needed)
2639
- name: Checkout repository
2740
uses: actions/checkout@v4
2841

29-
- name: Setup flutter
42+
# 🚀 Setup Flutter environment
43+
- name: Setup Flutter
3044
uses: subosito/flutter-action@v2
3145
with:
3246
flutter-version: ${{ env.FLUTTER_VERSION }}
3347
channel: "stable"
3448
cache: true
35-
cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache
36-
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
49+
cache-key: deps-${{ hashFiles('**/pubspec.lock') }}
50+
cache-path: ${{ runner.tool_cache }}/flutter
51+
52+
# 🧹 Clean Flutter pub cache to avoid stale SSH clones
53+
- name: Clean pub cache
54+
run: flutter pub cache clean || true
3755

56+
# 💎 Setup Fastlane (for both Android and iOS builds)
3857
- name: Setup Fastlane
3958
uses: ruby/setup-ruby@v1
4059
with:
4160
ruby-version: "3.3"
4261
bundler-cache: true
4362
working-directory: ${{ matrix.os }}
4463

64+
# 🔥 Setup Firebase environment variables
4565
- name: Setup Firebase env
4666
env:
4767
FIREBASE_ENV: ${{ secrets.FIREBASE_ENV }}
4868
run: ./scripts/setup-firebase.sh
4969

70+
# ☕️ Setup Java for Android builds
5071
- name: Setup Java
5172
if: matrix.os == 'android'
5273
uses: actions/setup-java@v4
5374
with:
5475
distribution: "temurin"
5576
java-version: "17"
5677

78+
# 🍏 Select the required Xcode version for iOS builds
5779
- name: Select Xcode version
5880
if: matrix.os == 'ios'
5981
uses: maxim-lobanov/setup-xcode@v1
6082
with:
6183
xcode-version: ${{ env.XCODE_VERSION }}
6284

85+
# ⚙️ Setup iOS environment (Fastlane match, certificates, etc.)
6386
- name: Setup iOS environment
6487
if: matrix.os == 'ios'
6588
run: ../scripts/setup-ios.sh
6689
working-directory: ${{ matrix.os }}
6790

91+
# 🛠️ Run prebuild tasks (code generation, assets, etc.)
6892
- name: Run prebuild
6993
run: ./scripts/prebuild.sh
7094

95+
# 🧱 Build development binaries (Android .apk / iOS .ipa)
7196
- name: Build
7297
env:
7398
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
7499
APPLE_CERTIFICATES_SSH_KEY: ${{ secrets.APPLE_CERTIFICATES_SSH_KEY }}
75100
run: ../scripts/build-dev.sh
76101
working-directory: ${{ matrix.os }}
77102

103+
# 📤 Upload build artifacts (APK or IPA)
78104
- name: Upload artifacts
79105
uses: actions/upload-artifact@v4
80106
with:

.github/workflows/gh-pages.yaml

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
paths:
44
- "**/*.dart"
55

6-
name: Deploy PR on Github Pages
6+
name: Deploy PR on GitHub Pages
77

88
env:
99
FLUTTER_VERSION: 3.32.8
@@ -20,7 +20,7 @@ jobs:
2020
url: ${{ steps.configure.outputs.URL }}
2121

2222
steps:
23-
# 🧹 Free up space before building
23+
# 🧹 Free up disk space before building to avoid "No space left" errors
2424
- name: Free up disk space before build
2525
run: |
2626
echo "=== Disk space before cleanup ==="
@@ -33,36 +33,52 @@ jobs:
3333
echo "=== Disk space after cleanup ==="
3434
df -h
3535
36-
# 🔄 Checkout code
36+
# 🔄 Checkout repository
3737
- name: Checkout repository
3838
uses: actions/checkout@v4
3939

40-
# 🧰 Setup Flutter
40+
# 🧰 Setup SSH for private Git dependencies (required for [email protected])
41+
- name: Set up SSH for private Git dependencies
42+
uses: webfactory/[email protected]
43+
with:
44+
ssh-private-key: ${{ secrets.SSH_KEY }}
45+
46+
# ⚙️ Add GitHub to known hosts to prevent "Host key verification failed"
47+
- name: Add GitHub to known hosts
48+
run: |
49+
mkdir -p ~/.ssh
50+
ssh-keyscan github.com >> ~/.ssh/known_hosts
51+
52+
# 🚀 Setup Flutter SDK
4153
- name: Setup Flutter
4254
uses: subosito/flutter-action@v2
4355
with:
4456
flutter-version: ${{ env.FLUTTER_VERSION }}
4557
channel: "stable"
4658
cache: true
47-
cache-key: deps-${{ hashFiles('**/pubspec.lock') }} # optional, change this to force refresh cache
48-
cache-path: ${{ runner.tool_cache }}/flutter # optional, change this to specify the cache path
59+
cache-key: deps-${{ hashFiles('**/pubspec.lock') }}
60+
cache-path: ${{ runner.tool_cache }}/flutter
4961

5062
# 🧹 Clean Flutter cache before building
5163
- name: Flutter clean
5264
run: flutter clean
5365

54-
# 📦 Run prebuild (if any)
66+
# 🧹 Optionally clean pub cache to avoid stale SSH clones
67+
- name: Clean pub cache
68+
run: flutter pub cache clean || true
69+
70+
# 📦 Run prebuild script (if any, e.g. code generation, assets)
5571
- name: Run prebuild
5672
run: ./scripts/prebuild.sh
5773

58-
# ⚙️ Configure environment for PR
74+
# ⚙️ Configure web environment for PR deployment
5975
- name: Configure environments
6076
id: configure
6177
env:
6278
FOLDER: ${{ github.event.pull_request.number }}
6379
run: ./scripts/configure-web-environment.sh
6480

65-
# 🧱 Build Flutter Web (release)
81+
# 🧱 Build Flutter Web (release mode)
6682
- name: Build Web (Release)
6783
env:
6884
FOLDER: ${{ github.event.pull_request.number }}
@@ -73,7 +89,7 @@ jobs:
7389
echo "=== Disk usage after build ==="
7490
df -h
7591
76-
# 🚀 Deploy to GitHub Pages
92+
# 🚀 Deploy to GitHub Pages (each PR has its own subfolder)
7793
- name: Deploy to GitHub Pages
7894
uses: peaceiris/actions-gh-pages@v4
7995
with:
@@ -82,7 +98,7 @@ jobs:
8298
keep_files: true
8399
publish_dir: "build/web"
84100

85-
# 🧹 Clean up after build to save space
101+
# 🧹 Cleanup after build to free up disk space
86102
- name: Cleanup after deploy
87103
if: always()
88104
run: |
@@ -91,7 +107,7 @@ jobs:
91107
echo "=== Disk usage after cleanup ==="
92108
df -h
93109
94-
# 💬 Create or update comments on PR
110+
# 💬 Find existing deployment comment on PR (if exists)
95111
- name: Find deployment comment
96112
uses: peter-evans/find-comment@v3
97113
id: fc
@@ -100,6 +116,7 @@ jobs:
100116
issue-number: ${{ github.event.pull_request.number }}
101117
body-includes: "This PR has been deployed to"
102118

119+
# 💬 Create or update the comment with the PR deployment URL
103120
- name: Create or update deployment comment
104121
uses: peter-evans/create-or-update-comment@v4
105122
with:

.github/workflows/image.yaml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,31 @@ on:
88
name: Build Docker images
99

1010
jobs:
11+
# 🧩 Build and push the development Docker image (triggered on master branch)
1112
build-dev-image:
1213
name: Build development image
1314
if: github.ref_type == 'branch' && github.ref_name == 'master'
1415
runs-on: ubuntu-latest
1516
environment: dev
1617

1718
steps:
19+
# 🧰 Setup SSH (needed for private git@ dependencies inside Docker build)
20+
- name: Set up SSH for private Git dependencies
21+
uses: webfactory/[email protected]
22+
with:
23+
ssh-private-key: ${{ secrets.SSH_KEY }}
24+
25+
# ⚙️ Add GitHub to known hosts (avoid host verification errors)
26+
- name: Add GitHub to known hosts
27+
run: |
28+
mkdir -p ~/.ssh
29+
ssh-keyscan github.com >> ~/.ssh/known_hosts
30+
31+
# ⚙️ Setup Docker Buildx (multi-platform builder)
1832
- name: Set up Docker Buildx
1933
uses: docker/setup-buildx-action@v3
2034

35+
# 🧩 Generate Docker image metadata (tags, labels)
2136
- name: Docker metadata
2237
id: meta
2338
uses: docker/metadata-action@v5
@@ -28,41 +43,58 @@ jobs:
2843
tags: |
2944
type=ref,event=branch
3045
46+
# 🔐 Login to Docker Hub
3147
- name: Login to Docker Hub
3248
uses: docker/login-action@v3
3349
with:
3450
username: ${{ secrets.DOCKERHUB_USERNAME }}
3551
password: ${{ secrets.DOCKERHUB_TOKEN }}
3652

53+
# 🔐 Login to GitHub Container Registry (GHCR)
3754
- name: Login to GitHub Container Registry
3855
uses: docker/login-action@v3
3956
with:
4057
registry: ghcr.io
4158
username: ${{ github.actor }}
4259
password: ${{ secrets.GITHUB_TOKEN }}
4360

61+
# 🏗️ Build and push the development image (with SSH forwarding)
4462
- name: Build and push image
4563
uses: docker/build-push-action@v5
4664
with:
4765
push: true
48-
platforms: "linux/amd64,linux/arm64"
49-
cache-from: |
50-
type=gha
51-
cache-to: |
52-
type=gha
66+
ssh: default # ✅ Forward SSH key into Docker for private git@ dependencies
67+
platforms: linux/amd64,linux/arm64
68+
cache-from: type=gha
69+
cache-to: type=gha
5370
tags: ${{ steps.meta.outputs.tags }}
5471
labels: ${{ steps.meta.outputs.labels }}
5572

73+
# 🚀 Build and push the production (release) Docker image (triggered on version tags)
5674
build-release-image:
5775
name: Build release image
5876
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
5977
runs-on: ubuntu-latest
6078
environment: prod
6179

6280
steps:
81+
# 🧰 Setup SSH (needed for private git@ dependencies inside Docker build)
82+
- name: Set up SSH for private Git dependencies
83+
uses: webfactory/[email protected]
84+
with:
85+
ssh-private-key: ${{ secrets.SSH_KEY }}
86+
87+
# ⚙️ Add GitHub to known hosts
88+
- name: Add GitHub to known hosts
89+
run: |
90+
mkdir -p ~/.ssh
91+
ssh-keyscan github.com >> ~/.ssh/known_hosts
92+
93+
# ⚙️ Setup Docker Buildx
6394
- name: Set up Docker Buildx
6495
uses: docker/setup-buildx-action@v3
6596

97+
# 🧩 Generate Docker image metadata for release tags
6698
- name: Docker metadata
6799
id: meta
68100
uses: docker/metadata-action@v5
@@ -74,27 +106,29 @@ jobs:
74106
type=ref,event=tag
75107
type=raw,value=release
76108
109+
# 🔐 Login to Docker Hub
77110
- name: Login to Docker Hub
78111
uses: docker/login-action@v3
79112
with:
80113
username: ${{ secrets.DOCKERHUB_USERNAME }}
81114
password: ${{ secrets.DOCKERHUB_TOKEN }}
82115

116+
# 🔐 Login to GitHub Container Registry (GHCR)
83117
- name: Login to GitHub Container Registry
84118
uses: docker/login-action@v3
85119
with:
86120
registry: ghcr.io
87121
username: ${{ github.actor }}
88122
password: ${{ secrets.GITHUB_TOKEN }}
89123

124+
# 🏗️ Build and push the release image (with SSH forwarding)
90125
- name: Build and push image
91126
uses: docker/build-push-action@v5
92127
with:
93128
push: true
94-
platforms: "linux/amd64,linux/arm64"
95-
cache-from: |
96-
type=gha
97-
cache-to: |
98-
type=gha
129+
ssh: default # ✅ Enable SSH forwarding during Docker build
130+
platforms: linux/amd64,linux/arm64
131+
cache-from: type=gha
132+
cache-to: type=gha
99133
tags: ${{ steps.meta.outputs.tags }}
100134
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)