Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): build web docker images
Browse files Browse the repository at this point in the history
JagandeepBrar committed Apr 19, 2022

Verified

This commit was signed with the committer’s verified signature.
JagandeepBrar Jagandeep Brar
1 parent 73c09cc commit a2f5125
Showing 8 changed files with 156 additions and 20 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.git/
.dart_tool/
android/
build/
docs/
ios/
linux/
localization/
macos/
node_modules/
shaders/
snap/
windows/
5 changes: 0 additions & 5 deletions .gitbook.yaml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/actions/prepare_for_deployment/action.yml
Original file line number Diff line number Diff line change
@@ -11,6 +11,14 @@ inputs:
description: 'App Store Connect API Key'
required: false
default: ''
ghcr-actor:
description: 'GitHub Container Registry Actor'
required: false
default: ''
ghcr-token:
description: 'GitHub Container Registry Token'
required: false
default: ''
google-play-key:
description: 'Google Play Store API Key'
required: false
@@ -52,6 +60,18 @@ runs:
with:
xcode-version: latest-stable

- name: Set up Docker Buildx
if: ${{ inputs.channel == 'docker' }}
uses: docker/setup-buildx-action@v1

- name: Setup GitHub Package Registry
if: ${{ inputs.channel == 'docker' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ inputs.ghcr-actor }}
password: ${{ inputs.ghcr-token }}

- name: Setup Secret Keys
shell: bash
run: |
59 changes: 56 additions & 3 deletions .github/workflows/build_web.yml
Original file line number Diff line number Diff line change
@@ -6,14 +6,17 @@ on:
build-number:
required: true
type: string
flavor:
required: true
type: string

secrets:
FIREBASE_TOKEN:
required: true

jobs:
build-canvaskit:
name: CanvasKit
build-hosted:
name: Hosted
runs-on: ubuntu-latest
steps:
- name: Setup Environment
@@ -28,5 +31,55 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: web-canvaskit
name: web-hosted
path: ${{ github.workspace }}/build/web

build-archive:
name: Archive
runs-on: ubuntu-latest
steps:
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
with:
platform: web

- name: Build LunaSea
run: npm run build:web

- name: Create Archive
uses: thedoctor0/zip-release@0.6.2
with:
type: zip
filename: output/lunasea-web-canvaskit.zip
directory: ${{ github.workspace }}/build/web

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: web-archive
path: ${{ github.workspace }}/output

build-docker:
name: Docker
runs-on: ubuntu-latest
steps:
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_build@master
with:
platform: web

- name: Build LunaSea
uses: docker/build-push-action@v2
with:
context: .
outputs: type=docker,dest=${{ github.workspace}}/output/lunasea-web-docker.tar
tags: |
ghcr.io/jagandeepbrar/lunasea:latest
ghcr.io/jagandeepbrar/lunasea:${{ inputs.flavor }}
ghcr.io/jagandeepbrar/lunasea:${{ github.sha }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: web-docker
path: ${{ github.workspace }}/output
35 changes: 34 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -183,6 +183,32 @@ jobs:
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: bundle exec fastlane deploy_appstore groups:${{ inputs.flavor }} pkg:${{ github.workspace }}/output/lunasea-macos-amd64.pkg

web-docker:
name: Docker
if: ${{ inputs.enable-web == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Setup Environment
uses: JagandeepBrar/LunaSea/.github/actions/prepare_for_deployment@master
with:
channel: docker
ghcr-actor: ${{ github.actor }}
ghcr-token: ${{ github.token }}

- name: Download Docker Image
uses: actions/download-artifact@v3
with:
name: web-docker
path: ${{ github.workspace }}/output

- name: Load Docker Image
run: |
docker load --input ${{ github.workspace}}/output/lunasea-web-docker.tar
docker image ls -a
- name: Deploy to GitHub Container Registry
run: docker image push --all-tags ghcr.io/jagandeepbrar/lunasea

web-netlify:
name: Netlify
if: ${{ inputs.enable-web == 'true' }}
@@ -196,7 +222,7 @@ jobs:
- name: Download Web Package
uses: actions/download-artifact@v3
with:
name: web-canvaskit
name: web-hosted
path: ${{ github.workspace }}/output

- name: Determine Release Channel
@@ -278,6 +304,13 @@ jobs:
name: windows-app-package
path: ${{ github.workspace }}/output

- name: Download Web Archive
if: ${{ inputs.enable-web == 'true' }}
uses: actions/download-artifact@v3
with:
name: web-archive
path: ${{ github.workspace }}/output

- name: Download Windows MSIX Installer
if: ${{ inputs.enable-windows == 'true' }}
uses: actions/download-artifact@v3
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -99,6 +99,7 @@ jobs:
uses: JagandeepBrar/LunaSea/.github/workflows/build_web.yml@master
with:
build-number: ${{ needs.prepare.outputs.build-number }}
flavor: ${{ github.event.inputs.flavor || 'edge' }}
secrets:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build
FROM debian:latest as build

ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:$PATH"
RUN apt-get update
RUN apt-get install -y curl git wget unzip
RUN apt-get clean

RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter
RUN flutter channel stable
RUN flutter upgrade

RUN mkdir /lunasea/
COPY . /lunasea/
WORKDIR /lunasea/
RUN flutter build web

# Runtime
FROM nginx:alpine
LABEL org.opencontainers.image.source="https://github.com/JagandeepBrar/LunaSea"
COPY --from=build /lunasea/build/web /usr/share/nginx/html
22 changes: 11 additions & 11 deletions lib/core/extensions/string.dart
Original file line number Diff line number Diff line change
@@ -29,6 +29,17 @@ extension StringExtension on String {

return split.join(_wordDelimiter);
}

Future<void> copyToClipboard({
bool showSnackBar = true,
}) async {
await Clipboard.setData(ClipboardData(text: this));
if (showSnackBar)
showLunaSuccessSnackBar(
title: 'Copied',
message: 'Copied content to the clipboard',
);
}
}

extension StringLinksExtension on String {
@@ -90,15 +101,4 @@ extension StringLinksExtension on String {
/// Attach this string as a series ID to TVMaze and attempt to launch it as a URL.
Future<void> lunaOpenTVMaze() async =>
await _openLink('https://www.tvmaze.com/shows/$this');

Future<void> copyToClipboard({
bool showSnackBar = true,
}) async {
await Clipboard.setData(ClipboardData(text: this));
if (showSnackBar)
showLunaSuccessSnackBar(
title: 'Copied',
message: 'Copied content to the clipboard',
);
}
}

0 comments on commit a2f5125

Please sign in to comment.