Skip to content

remove folder path from compilation output. increase compilation time… #18

remove folder path from compilation output. increase compilation time…

remove folder path from compilation output. increase compilation time… #18

name: "Build and push to ECR"
on:
push:
branches:
- main
jobs:
BuildAndDeploy:
name: "Build and Deploy"
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Build Rust binary
run: |
pip install cargo-lambda
cargo lambda build --release
- name: Cache cargo registry
uses: actions/cache@v4
continue-on-error: false
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-build-cache
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::417600709600:role/online-judge-rust-github-actions
role-session-name: GithubBuildAndDeploy
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: "online-judge-rust"
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image-uri=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- name: Update Lambda
run: |
aws lambda update-function-code --function-name online-judge-rust \
--image-uri "${{ steps.build-image.outputs.image-uri }}"