Skip to content

fix: github action

fix: github action #8

# This workflow builds a Docker image and pushes it to Amazon ECR
# when a commit is pushed to the 'main' branch.
name: Build and Push to ECR
on:
push:
branches:
- main # Trigger the workflow on pushes to the main branch
# Environment variables available to all jobs and steps
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: geosphere/gee
jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
# These permissions are required for OIDC authentication with AWS
permissions:
id-token: write # Required for assuming the IAM role
contents: read # Required for checking out the repository code
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_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: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}, ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:latest
cache-from: type=inline
cache-to: type=inline,mode=max