From 2a02289d49c2a465c966c149fbd0f782c360e58d Mon Sep 17 00:00:00 2001 From: Ehsan Aliakbar Date: Mon, 31 Jul 2023 23:45:54 +0330 Subject: [PATCH] replace circleci with github-ci --- .circleci/config.yml | 56 ----------------------------------- .github/workflows/publish.yml | 55 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 56 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/publish.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f093cfa..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,56 +0,0 @@ -# Golang CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/ for more details -version: 2 -jobs: - build_and_test: - working_directory: ~/prometheus-cardinality-exporter - machine: true - steps: - - checkout - - run: - name: Build Alpine Docker Image - command: | - docker build -f Dockerfile-builder . --rm=false -t thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1" - docker run --rm -it thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1" --help - - run: - name: Build distroless Docker Image - command: | - docker build -f Dockerfile-builder_distroless . --rm=false -t thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1"_distroless - docker run --rm -it thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1"_distroless --help - build_and_release: - working_directory: ~/prometheus-cardinality-exporter - machine: true - steps: - - checkout - - run: - name: Build Alpine Docker Image - command: | - docker build -f Dockerfile-builder . --rm=false -t thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1" - docker run --rm -it thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1" --help - - run: - name: Build distroless Docker Image - command: | - docker build -f Dockerfile-builder_distroless . --rm=false -t thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1"_distroless - docker run --rm -it thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1"_distroless --help - - run: - name: Publish Docker Images to Docker Hub - command: | - echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin - docker push thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1" - docker push thoughtmachine/prometheus-cardinality-exporter:"$CIRCLE_SHA1"_distroless -workflows: - version: 2 - build-master: - jobs: - - build_and_release: - context: conntest-dockerhub-release - filters: - branches: - only: master - test-buildable: - jobs: - - build_and_test: - filters: - branches: - ignore: master diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7149c8b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,55 @@ +name: Publish Docker image + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Normal Docker images + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Extract metadata (tags, labels) for Distroless Docker images + id: meta_distroless + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + suffix=_distroless,onlatest=true + + - name: Build and push Normal Docker image + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile-builder + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Distroless Docker image + uses: docker/build-push-action@v3 + with: + context: . + file: Dockerfile-builder_distroless + push: true + tags: ${{ steps.meta_distroless.outputs.tags }} + labels: ${{ steps.meta_distroless.outputs.labels }} \ No newline at end of file