Merge pull request #29 Add Dockerfile and CI workflow for fn-prevalen… #1
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
| --- | |
| # ABOUTME: Builds and pushes fn-prevalence-predictor Docker image to AWS ECR. | |
| # ABOUTME: Triggers on push to main/master branches and version tags. | |
| name: Build and Push Prevalence Predictor to ECR | |
| "on": | |
| push: | |
| branches: | |
| - main | |
| - master | |
| tags: | |
| - 'v*' | |
| paths: | |
| - 'fn-prevalence-predictor-1.3.0/**' | |
| - '.github/workflows/build-and-push-prevalence-predictor.yml' | |
| env: | |
| AWS_REGION: ${{ vars.AWS_REGION || 'eu-central-1' }} | |
| ECR_REPOSITORY: onaio/fn-prevalence-predictor | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials (OIDC) | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }} | |
| tags: | | |
| type=sha,prefix=,format=short | |
| type=ref,event=branch | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable=${{ | |
| startsWith(github.ref, 'refs/tags/v') }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./fn-prevalence-predictor-1.3.0 | |
| file: ./fn-prevalence-predictor-1.3.0/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: true | |
| sbom: true | |
| - name: Output image details | |
| env: | |
| REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| TAGS: ${{ steps.meta.outputs.tags }} | |
| run: | | |
| echo "## Prevalence Predictor image pushed to ECR" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Registry:** $REGISTRY" >> $GITHUB_STEP_SUMMARY | |
| echo "**Repository:** $ECR_REPOSITORY" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "$TAGS" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY |