feat(uptime): Optimize the status page and add support for new module… #82
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: Build Web Image | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'project/web/**' | |
| - '.github/workflows/web-build.yml' | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Image version (leave empty to use default generation rule) | |
| required: false | |
| type: string | |
| push_latest: | |
| description: 'Push as latest tag' | |
| required: false | |
| type: boolean | |
| default: false | |
| permissions: | |
| id-token: write | |
| contents: read | |
| env: | |
| IMAGE_REPO: aitoearn | |
| APP_NAME: aitoearn-web | |
| MONOREPO_DIR: project/web | |
| DOCKER_HUB_USERNAME: aitoearn | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ env.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
| - name: Generate version | |
| id: version | |
| run: | | |
| if [ -n "${{ github.event.inputs.version }}" ]; then | |
| VERSION="${{ github.event.inputs.version }}" | |
| else | |
| VERSION=$(date +%Y%m%d)-$(git rev-parse --short HEAD) | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Determine push latest | |
| id: push-latest | |
| run: | | |
| PUSH_LATEST=false | |
| if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| PUSH_LATEST=true | |
| echo "📌 Main branch push: Will push latest tag" | |
| elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ github.event.inputs.push_latest }}" = "true" ]; then | |
| PUSH_LATEST=true | |
| echo "📌 Manual trigger with push_latest: Will push latest tag" | |
| fi | |
| echo "push_latest=$PUSH_LATEST" >> $GITHUB_OUTPUT | |
| - name: Prepare tags | |
| id: tags | |
| run: | | |
| TAGS="${{ secrets.ECR_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.APP_NAME }}:${{ steps.version.outputs.version }}"$'\n'"${{ env.DOCKER_HUB_USERNAME }}/${{ env.APP_NAME }}:${{ steps.version.outputs.version }}" | |
| if [ "${{ steps.push-latest.outputs.push_latest }}" = "true" ]; then | |
| TAGS="$TAGS"$'\n'"${{ secrets.ECR_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.APP_NAME }}:latest"$'\n'"${{ env.DOCKER_HUB_USERNAME }}/${{ env.APP_NAME }}:latest" | |
| fi | |
| echo "tags<<EOF" >> $GITHUB_OUTPUT | |
| echo "$TAGS" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Build and push application | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ env.MONOREPO_DIR }}/ | |
| file: ${{ env.MONOREPO_DIR }}/Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.tags.outputs.tags }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Summary | |
| if: always() | |
| run: | | |
| echo "## 📦 Build Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "- **App**: ${{ env.APP_NAME }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version**: ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Platform**: linux/amd64" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🐳 ECR Images" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version Image**: \`${{ secrets.ECR_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.APP_NAME }}:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ steps.push-latest.outputs.push_latest }}" = "true" ]; then | |
| echo "- **Latest**: \`${{ secrets.ECR_REGISTRY }}/${{ env.IMAGE_REPO }}/${{ env.APP_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🐋 Docker Hub Images" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Version Image**: \`${{ env.DOCKER_HUB_USERNAME }}/${{ env.APP_NAME }}:${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ steps.push-latest.outputs.push_latest }}" = "true" ]; then | |
| echo "- **Latest**: \`${{ env.DOCKER_HUB_USERNAME }}/${{ env.APP_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### 🔗 Quick Links" >> $GITHUB_STEP_SUMMARY | |
| echo "- [Source Commit](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_STEP_SUMMARY | |
| echo "- [Build Log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY |