From ff6a3b44cca1f433dea2704b99b62f80cb9f8c64 Mon Sep 17 00:00:00 2001 From: Hiep Mai Date: Wed, 24 Jul 2024 13:47:07 +0700 Subject: [PATCH] feat: Add github actions --- .circleci/config.yml | 102 ---------------------------------- .github/workflows/ci.yml | 20 +++++++ .github/workflows/publish.yml | 24 ++++++++ 3 files changed, 44 insertions(+), 102 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index aa565d0..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,102 +0,0 @@ -version: 2.1 - -orbs: - go: circleci/go@1.7.3 - aws-ecr: circleci/aws-ecr@8.2.1 - -jobs: - build_lint_test: - machine: - image: ubuntu-2204:2024.01.1 - resource_class: large - steps: - - go/install: - version: "1.22.3" - - checkout - - run: - name: Print Go environment - command: "go env" - - go/load-cache: - key: go-mod-v6-{{ checksum "go.sum" }} - - go/mod-download - - go/save-cache: - key: go-mod-v6-{{ checksum "go.sum" }} - path: "/home/circleci/.go_workspace/pkg/mod" - - run: - name: Build cli app - command: make build - - run: - name: Lint - command: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2 - ./bin/golangci-lint run --timeout 5m0s - - run: - name: Run tests - command: | - make test - - run: - name: Run integration tests - command: | - make test-e2e - - build_docker: - machine: - image: ubuntu-2204:2024.01.1 - resource_class: large - steps: - - checkout - - aws-ecr/build-image: - push-image: false - dockerfile: Dockerfile - path: ./ - build-path: ./ - tag: "$CIRCLE_SHA1,$CIRCLE_TAG" - repo: "cli-tools" - - run: - name: Save Docker image to export it to workspace - command: | - docker save $(docker image ls --format '{{.Repository}}:{{.Tag}}') > /tmp/cli-tools.tar - - persist_to_workspace: - root: /tmp - paths: - - cli-tools.tar - - push_docker: - machine: - image: ubuntu-2204:2024.01.1 - resource_class: large - steps: - - attach_workspace: - at: /tmp - - run: - name: Load Docker image from workspace - command: | - docker load -i /tmp/cli-tools.tar - - aws-ecr/ecr-login: - aws-access-key-id: AWS_ACCESS_KEY_ID - aws-secret-access-key: AWS_SECRET_ACCESS_KEY - region: "$AWS_REGION" - - aws-ecr/push-image: - registry-id: AWS_ECR_REGISTRY_ID - region: "$AWS_REGION" - repo: "cli-tools" - tag: "$CIRCLE_SHA1,$CIRCLE_TAG" - -workflows: - CI: - jobs: - - build_lint_test - - build_docker: - filters: - tags: - only: /.*/ - - push_docker: - requires: - - build_docker - filters: - tags: - only: /.*/ - branches: - only: - - main - - dev diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..30ae593 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: ci + +on: + pull_request: + branches: + - '**' + +jobs: + lint_test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: true + run-lint: true + + docker_pipeline: + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + secrets: inherit + with: + publish: false \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..9231bc4 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: docker_publish + +on: + push: + branches: + - 'main' + - 'dev' + tags: + - '**' + +jobs: + lint_test: + uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0 + with: + run-unit-tests: true + run-integration-tests: true + run-lint: true + + docker_pipeline: + needs: ["lint_test"] + uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0 + secrets: inherit + with: + publish: true \ No newline at end of file