Skip to content

Commit

Permalink
ci: add Deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Rei-x committed Aug 5, 2024
1 parent 92d2b7c commit fb45531
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
API_URL="https://admin.topwr.solvro.pl/graphql"
ASSETS_URL="https://admin.topwr.solvro.pl/assets"
IPARKING_URL="https://iparking.pwr.edu.pl"
FIREBASE_NAME="CHANGE_ME"
FIREBASE_CLIENT_ID="CHANGE_ME"
FIREBASE_PRIVATE_KEY="CHANGE_ME"
FIREBASE_EMAIL="CHANGE_ME"
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy

on:
push:
branches: ["main"]

env:
REGISTRY: ghcr.io

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Add envs
run: cp .env.example .env

- name: Add firebase config
run: echo "${{ secrets.FIREBASE_CONFIG }}" > base64 --decode > lib/firebase_options.dart

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/Solvro/web-topwr-sci-clubs-form:latest
cache-from: type=registry,ref=ghcr.io/Solvro/web-topwr-sci-clubs-form:latest
cache-to: type=inline
network: host

- name: Trigger build
run: |
curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
2 changes: 1 addition & 1 deletion .github/workflows/lint_and_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: dart pub get

- name: Example .env
run: cp example.env .env
run: cp .env.example .env

- name: generate files
run: dart run build_runner build --delete-conflicting-outputs
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ app.*.symbols
.env
*.env.dev
.env.dev
!.env.example
env.g.dart
**/env.g.dart

Expand Down
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Install Operating system and dependencies
FROM ubuntu:20.04 AS build

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install -y curl git wget unzip libgconf-2-4 gdb libstdc++6 libglu1-mesa fonts-droid-fallback python3
RUN apt-get clean

ENV DEBIAN_FRONTEND=dialog

# download Flutter SDK from Flutter Github repo
RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter

# Set flutter environment path
ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}"

# Run flutter doctor
RUN flutter doctor

# Enable flutter web
RUN flutter channel stable
RUN flutter upgrade
RUN flutter config --enable-web

# Copy files to container and build
RUN mkdir /app/
COPY . /app/
WORKDIR /app/
RUN dart run build_runner build -d
RUN flutter build web --web-renderer html

FROM socialengine/nginx-spa:latest
COPY --chown=nginx:nginx --from=build ./build/web /app
EXPOSE 80
2 changes: 1 addition & 1 deletion lib/config/api_base_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class ApiBaseConfig {
path: ".env",
obfuscate: true,
useConstantCase: true,
requireEnvFile: true,
requireEnvFile: false,
)
abstract class ApiBaseEnv {
@EnviedField()
Expand Down

0 comments on commit fb45531

Please sign in to comment.