Skip to content

chore(deps): bump fl_chart from 1.1.1 to 1.2.0 #190

chore(deps): bump fl_chart from 1.1.1 to 1.2.0

chore(deps): bump fl_chart from 1.1.1 to 1.2.0 #190

name: Frontend Docker Build
on:
push:
branches: [main]
paths:
- 'lib/**'
- 'web/**'
- 'assets/**'
- 'pubspec.yaml'
- 'Dockerfile'
- '.github/workflows/frontend-docker.yml'
pull_request:
branches: [main]
paths:
- 'lib/**'
- 'web/**'
- 'assets/**'
- 'pubspec.yaml'
permissions:
contents: write
packages: write
env:
IMAGE_NAME: tellmemo-frontend
jobs:
build-and-push:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: version
run: |
# Get the latest frontend tag or start at 0.0.0
LATEST_TAG=$(git tag -l "frontend-v*" --sort=-v:refname | head -1 | sed 's/frontend-v//' || echo "0.0.0")
# Increment patch version
IFS='.' read -ra VER <<< "$LATEST_TAG"
MAJOR=${VER[0]:-0}
MINOR=${VER[1]:-0}
PATCH=${VER[2]:-0}
PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Building frontend version: $NEW_VERSION"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Setup configuration
run: |
# Update config.dart for Docker environment with specified values
# Set API Backend URL to Docker backend service
sed -i "s|static const String apiBaseUrl = '.*'|static const String apiBaseUrl = 'http://localhost:8000'|g" lib/config.dart
# Set environment to development
sed -i "s|static const String environment = '.*'|static const String environment = 'development'|g" lib/config.dart
# Set authentication provider to backend
sed -i "s|static const String authProvider = '.*'|static const String authProvider = 'backend'|g" lib/config.dart
# Enable logging
sed -i "s|static const bool enableLogging = [^;]*;|static const bool enableLogging = true;|g" lib/config.dart
# Disable debug mode
sed -i "s|static const bool enableDebugMode = [^;]*;|static const bool enableDebugMode = false;|g" lib/config.dart
# Disable Sentry
sed -i "s|static const bool sentryEnabled = [^;]*;|static const bool sentryEnabled = false;|g" lib/config.dart
# Clear Sentry DSN (handle multiline const)
perl -i -0pe "s/static const String sentryDsn =\s*\n?\s*'[^']*';/static const String sentryDsn = '';/g" lib/config.dart
# Disable Firebase Analytics (handle multiline const)
perl -i -0pe 's/static const bool firebaseAnalyticsEnabled =\s*\n?\s*[^;]*;/static const bool firebaseAnalyticsEnabled = false;/g' lib/config.dart
# Clear Supabase URL
sed -i "s|static const String supabaseUrl = '.*'|static const String supabaseUrl = ''|g" lib/config.dart
# Clear Supabase Anon Key
sed -i "s|static const String supabaseAnonKey = '.*'|static const String supabaseAnonKey = ''|g" lib/config.dart
echo "Configuration updated for Docker environment"
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
# Configuration is baked into the image from lib/config.dart
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.ref == 'refs/heads/main' && 'latest' || 'develop' }}
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create git tag
uses: actions/github-script@v7
with:
script: |
const tagName = 'refs/tags/frontend-v${{ steps.version.outputs.version }}';
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: tagName,
sha: context.sha
});
console.log(`Created tag: ${tagName}`);
} catch (error) {
if (error.status === 422) {
console.log(`Tag ${tagName} already exists, skipping creation`);
} else {
throw error;
}
}
- name: Create GitHub Release
uses: actions/github-script@v7
with:
script: |
const tagName = `frontend-v${{ steps.version.outputs.version }}`;
const releaseName = `Frontend v${{ steps.version.outputs.version }}`;
const branch = '${{ github.ref }}' === 'refs/heads/main' ? 'main' : 'develop';
const version = '${{ steps.version.outputs.version }}';
const sha = '${{ github.sha }}';
const dockerUsername = '${{ secrets.DOCKER_USERNAME }}';
const imageName = '${{ env.IMAGE_NAME }}';
const commitMessage = `${{ github.event.head_commit.message }}`.replace(/`/g, '\\`').replace(/\$/g, '\\$');
const bodyText = '## Frontend Release v' + version + '\n\n' +
'Branch: ' + branch + '\n' +
'Commit: ' + sha + '\n\n' +
'Docker Images:\n' +
'- `' + dockerUsername + '/' + imageName + ':' + version + '`\n' +
'- `' + dockerUsername + '/' + imageName + ':' + (branch === 'main' ? 'latest' : 'develop') + '`\n' +
'- `' + dockerUsername + '/' + imageName + ':' + sha + '`\n\n' +
'Changes:\n' + commitMessage;
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tagName,
name: releaseName,
body: bodyText,
draft: false,
prerelease: branch !== 'main'
});