From 9c8f50f0844555ac4d1fc147eb1f461b09f3850b Mon Sep 17 00:00:00 2001 From: yangwenz Date: Sun, 2 Jun 2024 15:15:35 +0800 Subject: [PATCH] Production ready version --- .github/workflows/build-ecr.yml | 40 +++++++++++++++++++++++++++++++++ .github/workflows/build.yml | 38 +++++++++++++++++++++++++++++++ .github/workflows/test.yml | 25 +++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 .github/workflows/build-ecr.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build-ecr.yml b/.github/workflows/build-ecr.yml new file mode 100644 index 0000000..7851519 --- /dev/null +++ b/.github/workflows/build-ecr.yml @@ -0,0 +1,40 @@ +name: Create a new release tag + +on: + push: + tags: + - 'v*.*.*-ecr' + +jobs: + + create-tag: + name: Build image + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set github env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: 'true' + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: serving-agent + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$RELEASE_VERSION . + docker push -a $ECR_REGISTRY/$ECR_REPOSITORY diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8177302 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Create a new release tag + +on: + push: + tags: + - 'v*.*.*' + +jobs: + + create-tag: + name: Build docker image + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Set github env + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Set gCloud auth + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + + - name: Install gCloud CLI + uses: google-github-actions/setup-gcloud@v1 + with: + project_id: ${{ secrets.GOOGLE_PROJECT }} + + - name: Build, tag, and push image + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + REPOSITORY: serving-agent + run: | + gcloud auth configure-docker asia-southeast1-docker.pkg.dev + docker build -t asia-southeast1-docker.pkg.dev/$GOOGLE_PROJECT/ml-platform/$REPOSITORY:$RELEASE_VERSION . + docker push asia-southeast1-docker.pkg.dev/$GOOGLE_PROJECT/ml-platform/$REPOSITORY:$RELEASE_VERSION diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..14185ff --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Unit tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + tests: + name: Test + runs-on: ubuntu-latest + + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.21 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Run unit tests + run: make test