revamp listener (#1525) #106
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: API Deploy to Amazon ECR | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- "api/**" | |
workflow_dispatch: | |
env: | |
ecr_url: public.ecr.aws/bisonai/orakl-api | |
jobs: | |
prepare: | |
name: Prepare Build | |
runs-on: ubuntu-latest | |
outputs: | |
tag_date: ${{ steps.tag.outputs.date }} | |
tag_git_hash: ${{ steps.tag.outputs.git_hash }} | |
version: ${{ steps.package.outputs.version }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get time TAG | |
id: tag | |
run: | | |
echo "date=$(date +'%Y%m%d.%H%M')" >> $GITHUB_OUTPUT | |
echo "git_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get package version | |
id: package | |
run: | | |
version=$(cat "./api/.version") | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: prepare | |
permissions: | |
id-token: write | |
contents: read | |
outputs: | |
tag_date: ${{ steps.tag.outputs.date }} | |
tag_git_hash: ${{ steps.tag.outputs.git_hash }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.22.3" | |
check-latest: true | |
cache-dependency-path: | | |
./api/go.sum | |
- name: Run lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.54 | |
working-directory: api | |
skip-pkg-cache: true | |
skip-build-cache: true | |
args: --timeout=10m | |
- name: Run Vet | |
run: | | |
cd ./api | |
go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow@latest | |
go vet | |
go vet -vettool=$(which shadow) | |
- name: Docker build orakl-api | |
run: SERVICE_NAME=orakl-api docker compose -f docker-compose.build.yaml build | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-region: us-east-1 | |
role-to-assume: ${{ secrets.ROLE_ARN }} | |
- name: Login to Amazon ECR | |
id: login-ecr-public | |
uses: aws-actions/amazon-ecr-login@v1 | |
with: | |
registry-type: public | |
- name: Publish Image to ECR(api) | |
run: | | |
docker tag orakl-api ${{ env.ecr_url }}:latest | |
docker push ${{ env.ecr_url }}:latest | |
docker tag ${{ env.ecr_url}}:latest ${{ env.ecr_url }}:v${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }} | |
docker push ${{ env.ecr_url }}:v${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }} | |
# After Migration => uncommented | |
# create-helmchart-pr: | |
# needs: [prepare, build] | |
# uses: ./.github/workflows/create-helmchart-pr.yaml | |
# with: | |
# project-name: "api" | |
# version: ${{ needs.prepare.outputs.version }} | |
# tag_date: ${{ needs.prepare.outputs.tag_date }} | |
# tag_git_hash: ${{ needs.prepare.outputs.tag_git_hash }} | |
# secrets: | |
# PAT: ${{ secrets.PAT }} |