fix: Resolve Sentry errors for insight validation, notifications, WebSocket, and telemetry #238
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Backend Docker Build | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'backend/**' | |
| - '.github/workflows/backend-docker.yml' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'backend/**' | |
| permissions: | |
| contents: write | |
| packages: write | |
| actions: write | |
| env: | |
| IMAGE_NAME: tellmemo-backend | |
| 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 backend tag or start at 0.0.0 | |
| LATEST_TAG=$(git tag -l "backend-v*" --sort=-v:refname | head -1 | sed 's/backend-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 backend 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: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./backend | |
| file: ./backend/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| 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/backend-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 = `backend-v${{ steps.version.outputs.version }}`; | |
| const releaseName = `Backend 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 = '## Backend 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' | |
| }); |