feat(api): migrate wake API to OpenAPI spec #128
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: CI — Build & Push to ECR | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: {} | |
| env: | |
| AWS_REGION: us-east-1 | |
| ECR_REPOSITORY: ecs-demo-app | |
| IMAGE_TAG: ${{ github.sha }} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build_and_push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Configure AWS (OIDC) | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: arn:aws:iam::097635932419:role/github-actions-ecs-role | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Ensure ECR repo exists | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| aws ecr describe-repositories --repository-names "$ECR_REPOSITORY" --region "$AWS_REGION" >/dev/null 2>&1 \ | |
| || aws ecr create-repository --repository-name "$ECR_REPOSITORY" --region "$AWS_REGION" >/dev/null | |
| - name: Compute ECR URL | |
| id: ecr | |
| run: | | |
| ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) | |
| echo "ECR_URL=${ACCOUNT_ID}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPOSITORY }}" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build (PR) — multi-arch, no push | |
| if: ${{ github.event_name == 'pull_request' }} | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| -f app/Dockerfile \ | |
| -t "${{ steps.ecr.outputs.ECR_URL }}:${{ env.IMAGE_TAG }}" \ | |
| app | |
| - name: Build & Push (main/dispatch) | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| -f app/Dockerfile \ | |
| -t "${{ steps.ecr.outputs.ECR_URL }}:${{ env.IMAGE_TAG }}" \ | |
| app --push | |
| - name: Output image refs | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| echo "Built (no push for pull_request):" | |
| else | |
| echo "Pushed:" | |
| fi | |
| echo " ${{ steps.ecr.outputs.ECR_URL }}:${{ env.IMAGE_TAG }}" | |
| - name: Publish build summary | |
| if: ${{ success() }} | |
| run: | | |
| cat << EOF >> "$GITHUB_STEP_SUMMARY" | |
| # Docker Image Build Summary | |
| - Repository: \`${{ env.ECR_REPOSITORY }}\` | |
| - Region: \`${{ env.AWS_REGION }}\` | |
| - Image: \`${{ steps.ecr.outputs.ECR_URL }}:${{ env.IMAGE_TAG }}\` | |
| - Event: \`${{ github.event_name }}\` | |
| - Commit: \`${{ github.sha }}\` | |
| - Actor: \`${{ github.actor }}\` | |
| - Run: \`${{ github.run_number }}\` | |
| EOF | |
| - name: Comment on PR with build result | |
| if: ${{ github.event_name == 'pull_request' && success() }} | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const body = ` | |
| ## Docker build result | |
| - Repository: \`${process.env.ECR_REPOSITORY}\` | |
| - Region: \`${process.env.AWS_REGION}\` | |
| - Image tag (PR SHA): \`${process.env.IMAGE_TAG}\` | |
| - Workflow run: \`${process.env.GITHUB_RUN_NUMBER}\` | |
| Build for this pull request finished successfully (image built, not pushed). | |
| `; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); |