Skip to content

updated some fix

updated some fix #49

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Dart
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# with:
# repository: Rakibul73/rtc_project_frontend_main
# token: ${{ secrets.TARGET_REPO_ACCESS_TOKEN }}
# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
- uses: dart-lang/setup-dart@v1
# - uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
with:
sdk: "3.2.0"
# - name: Install dependencies
# run: flutter pub get
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
flutter-version: 3.16.0
- name: flutter version check
run: flutter doctor -v
# Build for web
- name: Install dependencies
run: flutter pub get
- name: Build Flutter web
run: flutter build web --release
- name: Copy assets to build folder
run: cp -r assets/* build/web/assets/
- name: Comment out <base href="/"> in index.html
run: |
sed -i '17s|<base href="/">|<!-- <base href="/"> -->|' build/web/index.html
- name: List files in build/web/assets
run: ls -R build/web/assets
- name: Checkout target repository
uses: actions/checkout@v2
with:
repository: Rakibul73/rtc_project_frontend_build # Replace with your target repository
token: ${{ secrets.TARGET_REPO_ACCESS_TOKEN }}
path: target-repo
- name: Clean up old builds, preserve README.md, Copy build files to target repository, Fetch last commit information & Update README in target repository, Commit and push
run: |
cp target-repo/README.md README_backup.md
rm -rf target-repo/*
cat README_backup.md
cp -r build/web/* target-repo/
last_commit_message=$(git log -1 --pretty=%B)
last_commit_time=$(git log -1 --pretty=%cd)
new_entry="| $last_commit_message | $last_commit_time |"
{ echo "| Commit Message | Commit Time |"; echo "| -------------- | ----------- |"; echo "$new_entry"; tail -n +3 README_backup.md; } > target-repo/README.md
cat target-repo/README.md
cd target-repo
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Updated build for - $last_commit_message"
git push origin main
- name: Clean up old builds
run: rm -rf build/web
# ======================================
# Direct deploy to netlify
# Ensure you have already configured your Netlify site
# and have the NETLIFY_AUTH_TOKEN from your Netlify account.
# This workflow will trigger on every push to the main branch,
# build your Flutter web project,
# comment out the specified line in index.html,
# and deploy the result to Netlify.
# - name: Install Netlify CLI
# run: npm install -g netlify-cli
# - name: Deploy to Netlify
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# run: netlify deploy --dir=build/web --prod