Didn't I remove signal? #80
Workflow file for this run
This file contains 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: oioi-agent-image-push | |
on: | |
push: | |
paths: | |
- "oioi/**" | |
- ".github/workflows/oioi-agent-image-push.yml" | |
# push: | |
# branches: | |
# - master | |
# pull_request: | |
concurrency: | |
group: ${{ github.ref }}-oioi-agent-image-push | |
cancel-in-progress: true | |
env: | |
AWS_ACCOUNT_ID: 962920162112 | |
AWS_DEFAULT_REGION: ap-northeast-2 | |
CDK_DEFAULT_ACCOUNT: 962920162112 | |
CDK_DEFAULT_REGION: ap-northeast-2 | |
CARGO_VERSION: 1.74.0 | |
RUST_CACHE_PATHS: | | |
~/.cargo/ | |
oioi/agent/target/ | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
oioi-agent-image-push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# -- Agent Rust Build | |
- uses: actions/cache/restore@v3 | |
id: restore-cache | |
with: | |
path: ${{ env.RUST_CACHE_PATHS }} | |
key: ${{ runner.os }}-${{ env.CARGO_VERSION }}-oioi-${{ hashFiles('oioi/agent/Cargo.lock') }}-musl | |
- name: Set up rust | |
run: | | |
rustup toolchain install ${{ env.CARGO_VERSION }} --profile minimal | |
rustup default ${{ env.CARGO_VERSION }} | |
- name: Set up aarch64 cross-compilation | |
run: | | |
rustup target add aarch64-unknown-linux-musl | |
sudo apt-get install -y gcc-aarch64-linux-gnu | |
- name: Build agent | |
working-directory: oioi/agent | |
run: | | |
cargo build --release --target aarch64-unknown-linux-musl | |
- uses: actions/cache/save@v3 | |
with: | |
path: ${{ env.RUST_CACHE_PATHS }} | |
key: ${{ steps.restore-cache.outputs.cache-primary-key }} | |
# -- Docker | |
- uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/github-actions-role | |
aws-region: us-east-1 # for public ECR | |
- name: Login to Amazon ECR | |
id: login-ecr-public | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
registry-type: public | |
- name: Build, tag, and push docker image to Amazon ECR Public | |
env: | |
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} | |
REGISTRY_ALIAS: o4b6l4b3 # should be replaced to namseent after the alias is approved by AWS. | |
REPOSITORY: oioi | |
IMAGE_TAG: ${{ github.sha }} | |
working-directory: oioi/agent | |
run: | | |
IMAGE_PATH=$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY | |
for i in "linux/arm64 aarch64-unknown-linux-musl" | |
do | |
set -- $i # Convert the "tuple" into the param args $1 $2... | |
docker build \ | |
-t $IMAGE_PATH:$IMAGE_TAG \ | |
-t $IMAGE_PATH:latest \ | |
--platform $1 \ | |
--build-arg TARGET=$2 \ | |
--push \ | |
--cache-to mode=max,image-manifest=true,oci-mediatypes=true,type=registry,ref=$IMAGE_PATH:cache \ | |
--cache-from type=registry,ref=$IMAGE_PATH:cache \ | |
. | |
done | |
# -- CDK | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: "npm" | |
cache-dependency-path: | | |
oioi/cdk/package-lock.json | |
oioi/oioi-test-cdk/package-lock.json | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::${{ env.CDK_DEFAULT_ACCOUNT }}:role/github-actions-role | |
aws-region: ${{ env.CDK_DEFAULT_REGION }} | |
- name: Deploy test cdk | |
working-directory: oioi | |
run: | | |
export BRANCH_NAME=$(echo "${{ github.event.ref }}" | tr "[:upper:]" "[:lower:]" | sed -e "s#refs/heads/##g" -e 's/\//-/g' -e 's/|/-/g') | |
echo $BRANCH_NAME | |
export STACK_NAME=$(echo $BRANCH_NAME | tr "[:upper:]" "[:lower:]" | tr -cd '[:alnum:]') | |
echo $STACK_NAME | |
cd cdk | |
npm ci | |
npm run build | |
cd ../oioi-test-cdk | |
npm ci | |
npx cdk bootstrap | |
npx cdk deploy --require-approval never | |
DNS_NAME=$(aws cloudformation describe-stacks \ | |
--stack-name $STACK_NAME \ | |
--query "Stacks[0].Outputs[?OutputKey=='LoadBalancerDnsName'].OutputValue" \ | |
--output text) | |
echo $DNS_NAME | |
retries=0 | |
MAX_RETRIES=30 | |
RETRY_INTERVAL=10 | |
SUCCESS=false | |
while [ $retries -lt $MAX_RETRIES ]; do | |
response=$(curl -s -o /dev/null -w "%{http_code}" http://$DNS_NAME) | |
if [ $response -eq 200 ]; then | |
echo "HTTP Endpoint check successful." | |
SUCCESS=true | |
break | |
else | |
echo "Retrying in $RETRY_INTERVAL seconds..." | |
sleep $RETRY_INTERVAL | |
retries=$((retries+1)) | |
fi | |
done | |
if [ "$SUCCESS" = false ] ; then | |
echo "HTTP Endpoint check failed." | |
exit 1 | |
fi | |
aws cloudformation delete-stack --stack-name $STACK_NAME |