diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100755 index 512424b..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,61 +0,0 @@ -version: 2.1 -orbs: - kubernetes: circleci/kubernetes@1.3.1 -jobs: - build: - machine: true - steps: - - checkout - - run: echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin - - run: docker build -t openq/openq-coinapi:$CIRCLE_TAG . - - run: docker push openq/openq-coinapi:$CIRCLE_TAG - pushHelm: - machine: true - steps: - - checkout - - run: echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin - - run: - name: Update DEPLOY_ENV environment variable using CIRCLE_TAG - command: | - echo 'export DEPLOY_ENV=$(echo ${CIRCLE_TAG} | sed 's/-.*//')' >> $BASH_ENV - source $BASH_ENV - - run: echo $DEPLOY_ENV - - run: - command: | - wget https://github.com/mikefarah/yq/releases/download/v4.27.5/yq_linux_386 - sudo mv yq_linux_386 /usr/local/bin/yq - sudo chmod +x /usr/local/bin/yq - git clone https://${CIRCLECI_PAT}@github.com/openqdev/OpenQ-Helm.git - cd OpenQ-Helm/ - yq -i '.coinapi.image.tag = env(CIRCLE_TAG)' values-$DEPLOY_ENV.yaml - cat values-$DEPLOY_ENV.yaml - git add . - git commit -m "[CIRCLE CI] ${CIRCLE_TAG}" - git remote set-url origin https://${CIRCLECI_PAT}@github.com/openqdev/OpenQ-Helm.git - git push - git tag -f ${CIRCLE_TAG} - git push -f origin ${CIRCLE_TAG} --tags -workflows: - version: 2 - build-and-deploy: - jobs: - - build: - context: OpenQ - filters: - branches: - ignore: /.*/ - tags: - only: - - /^staging.*/ - - /^production.*/ - - pushHelm: - context: OpenQ - requires: - - build - filters: - branches: - ignore: /.*/ - tags: - only: - - /^staging.*/ - - /^production.*/ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fa03b36 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,51 @@ +#git add . && git commit -m "updates" && git push && git tag -f staging-1.0.0 && git push origin -f staging-1.0.1 +name: Build + Push OpenQ-CoinAPI + +on: + push: + tags: + - "staging-*" + - "production-*" + +jobs: + build: + outputs: + ENVIRONMENT: ${{ steps.extract_environment.outputs.ENVIRONMENT }} + name: Build OpenQ-CoinAPI + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Extract environment from tag + id: extract_environment + run: | + ENVIRONMENT=$(echo "${{ github.ref_name }}" | sed 's/-.*//') + echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV + echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker build + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: openq/openq-coinapi:${{ github.ref_name }} + tagHelm: + needs: build + uses: OpenQDev/OpenQ-Workflows/.github/workflows/tag.yml@main + with: + APP: coinapi + VERSION: ${{ github.ref_name }} + ENVIRONMENT: ${{ needs.build.outputs.ENVIRONMENT }} + secrets: + PAT: ${{ secrets.PAT }} diff --git a/Dockerfile b/Dockerfile index 6321c23..5dd48a9 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,8 @@ FROM node:18.14.1-alpine WORKDIR /app -RUN apk update && apk upgrade && \ - apk add --no-cache bash git +RUN apk update && apk upgrade && apk add --no-cache bash git COPY package.json . RUN yarn COPY . . EXPOSE 8080 -ENTRYPOINT yarn start \ No newline at end of file +ENTRYPOINT yarn start diff --git a/Dockerfile.dev b/Dockerfile.dev index 8326317..eb9a795 100755 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,7 +1,6 @@ FROM node:18.14.1-alpine WORKDIR /app -RUN apk update && apk upgrade && \ - apk add --no-cache bash git +RUN apk update && apk upgrade && apk add --no-cache bash git COPY package.json . RUN yarn install COPY . .