-
Notifications
You must be signed in to change notification settings - Fork 119
129 lines (108 loc) · 4.17 KB
/
image-sentry.yaml
File metadata and controls
129 lines (108 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
name: Build Docker images with Sentry
permissions:
contents: read
packages: write
id-token: write
jobs:
build-release-image-with-sentry:
name: Build release image with Sentry
if: github.event_name == 'workflow_dispatch' || (github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v'))
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract app version from pubspec.yaml
id: app_version
run: |
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ github.repository_owner }}/tmail-web
ghcr.io/${{ github.repository_owner }}/tmail-web
tags: |
type=ref,event=tag
type=raw,value=release
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image (release)
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
cache-from: |
type=gha
cache-to: |
type=gha
build-args: |
FLUTTER_VERSION=3.32.8
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG=${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }}
SENTRY_URL=${{ secrets.SENTRY_URL }}
SENTRY_RELEASE=${{ steps.app_version.outputs.version }}
GITHUB_SHA=${{ github.sha }}
VCS_REF=${{ github.repository }}@${{ github.sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Extract sourcemaps from Docker image
if: always()
run: |
# Get the first image tag (for amd64 platform)
IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1)
if [ -z "$IMAGE_TAG" ]; then
echo "No image tag found, skipping sourcemap extraction"
exit 0
fi
echo "Extracting sourcemaps from image: $IMAGE_TAG"
# Create temporary container to extract files
CONTAINER_ID=$(docker create --platform linux/amd64 "$IMAGE_TAG" 2>/dev/null | head -n1)
if [ -n "$CONTAINER_ID" ]; then
echo "Created container: $CONTAINER_ID"
# Create directory for sourcemaps
mkdir -p sourcemaps
# Copy all files from container
docker cp "$CONTAINER_ID:/usr/share/nginx/html/." sourcemaps/ 2>/dev/null || true
# Remove container
docker rm "$CONTAINER_ID" 2>/dev/null || true
# Filter only .map files and keep directory structure
find sourcemaps -type f ! -name "*.map" -delete 2>/dev/null || true
echo "Sourcemaps extracted:"
find sourcemaps -name "*.map" | head -10 || echo "No .map files found"
MAP_COUNT=$(find sourcemaps -name "*.map" 2>/dev/null | wc -l)
echo "Total .map files: $MAP_COUNT"
else
echo "Warning: Could not create container from image"
fi
- name: Upload sourcemaps as artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: sourcemaps-${{ steps.app_version.outputs.version }}
path: sourcemaps/**/*.map
retention-days: 30
if-no-files-found: warn