Skip to content

Commit 628b11e

Browse files
authored
Merge pull request #71 from codingpot/feat-add-chrome-app
feat: create a gRPC-Web Flutter
2 parents 7733a4c + 24ab19a commit 628b11e

File tree

5 files changed

+42
-7
lines changed

5 files changed

+42
-7
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,29 @@ jobs:
6363
namespace: kkweon
6464

6565
- uses: okteto/pipeline@master
66+
67+
deploy-to-gh-pages:
68+
runs-on: ubuntu-latest
69+
70+
if: github.ref == 'refs/heads/main'
71+
72+
needs:
73+
- flutter-build
74+
75+
defaults:
76+
run:
77+
working-directory: client
78+
steps:
79+
- uses: actions/checkout@v2
80+
- uses: actions/setup-java@v1
81+
with:
82+
java-version: "12.x"
83+
- uses: subosito/flutter-action@v1
84+
with:
85+
channel: "stable"
86+
- run: flutter pub get
87+
- run: flutter build web --release
88+
- uses: JamesIves/github-pages-deploy-action@4.1.4
89+
with:
90+
branch: gh-pages
91+
folder: build/web
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'package:grpc/grpc.dart';
2+
3+
ClientChannel getKkweonOktetoChannel() {
4+
return ClientChannel('ingress-kkweon.cloud.okteto.net');
5+
}

client/lib/grpc_channel_web.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'package:grpc/grpc_web.dart';
2+
3+
GrpcWebClientChannel getKkweonOktetoChannel() {
4+
return GrpcWebClientChannel.xhr(
5+
Uri.parse("https://envoy-kkweon.cloud.okteto.net/"));
6+
}

client/lib/service.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import 'package:grpc/grpc.dart';
2+
import 'package:pr12er/grpc_channel_native.dart'
3+
if (dart.library.js) 'package:pr12er/grpc_channel_web.dart';
24
import 'package:pr12er/protos/pkg/pr12er/messages.pb.dart';
35

46
import 'protos/pkg/pr12er/service.pbgrpc.dart';
@@ -7,7 +9,7 @@ class GrpcClient {
79
// Use _getLocalhostChannel(port: 9000) to use the localhost version.
810
// NOTE: localhost only works in iOS.
911
final Pr12erServiceClient _client =
10-
Pr12erServiceClient(_getKkweonOktetoChannel());
12+
Pr12erServiceClient(getKkweonOktetoChannel());
1113

1214
Future<String> sendMessage(String message) async {
1315
final request = HelloRequest()..body = message;
@@ -31,10 +33,6 @@ class GrpcClient {
3133
}
3234
}
3335

34-
ClientChannel _getKkweonOktetoChannel() {
35-
return ClientChannel('ingress-kkweon.cloud.okteto.net');
36-
}
37-
3836
// ignore: unused_element
3937
ClientChannel _getLocalhostChannel({required int port}) {
4038
return ClientChannel(

client/web/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
For more details:
1212
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
1313
-->
14-
<base href="/">
14+
<base href="/pr12er/">
1515

1616
<meta charset="UTF-8">
1717
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
@@ -95,4 +95,4 @@
9595
}
9696
</script>
9797
</body>
98-
</html>
98+
</html>

0 commit comments

Comments
 (0)