From ec6e92ebea1141037dbd4a0ce2dbb9170b025ca1 Mon Sep 17 00:00:00 2001 From: afrinaldipdg <107689282+afrinaldipdg@users.noreply.github.com> Date: Fri, 20 Oct 2023 19:35:49 +0700 Subject: [PATCH 1/4] CircleCI Commit --- .circleci/config.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..4175da6cf --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,26 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/configuration-reference +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/configuration-reference/#jobs +jobs: + say-hello: + # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/configuration-reference/#executor-job + docker: + - image: cimg/base:stable + # Add steps to the job + # See: https://circleci.com/docs/configuration-reference/#steps + steps: + - checkout + - run: + name: "Say hello" + command: "echo Hello, World!" + +# Orchestrate jobs using workflows +# See: https://circleci.com/docs/configuration-reference/#workflows +workflows: + say-hello-workflow: + jobs: + - say-hello From 266d582c967d4203a40d8761e19a51b9f7700d67 Mon Sep 17 00:00:00 2001 From: afrinaldipdg <107689282+afrinaldipdg@users.noreply.github.com> Date: Fri, 20 Oct 2023 20:24:58 +0700 Subject: [PATCH 2/4] Add .circleci/config.yml --- .circleci/config.yml | 51 +++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4175da6cf..d68fd77f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,26 +1,43 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/configuration-reference version: 2.1 - -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/configuration-reference/#jobs jobs: - say-hello: - # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/configuration-reference/#executor-job + lint-dockerfile: + docker: + - image: circleci/golang:1.16 + steps: + - checkout + - run: + name: Install hadolint + command: | + curl -Lo /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64 + chmod +x /usr/local/bin/hadolint + - run: + name: Run hadolint on Dockerfile + command: hadolint Dockerfile + + build-app-karsajobs-ui: docker: - - image: cimg/base:stable - # Add steps to the job - # See: https://circleci.com/docs/configuration-reference/#steps + - image: circleci/node:14 steps: - checkout - run: - name: "Say hello" - command: "echo Hello, World!" + name: Build and push Docker image for karsajobs-ui + command: | + # Build your karsajobs-ui application + docker build -t ghcr.io/afrinaldipdg/karsajobs-ui:${CIRCLE_SHA1} . + docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN + docker push ghcr.io/afrinaldipdg/karsajobs-ui:${CIRCLE_SHA1} -# Orchestrate jobs using workflows -# See: https://circleci.com/docs/configuration-reference/#workflows workflows: - say-hello-workflow: + version: 2 + build: jobs: - - say-hello + - lint-dockerfile: + filters: + branches: + only: + - karsajobs-ui + - build-app-karsajobs-ui: + filters: + branches: + only: + - karsajobs-ui \ No newline at end of file From c601acddf41846e64438d3321bf3732a35cfc9e2 Mon Sep 17 00:00:00 2001 From: afrinaldipdg <107689282+afrinaldipdg@users.noreply.github.com> Date: Fri, 20 Oct 2023 22:39:42 +0700 Subject: [PATCH 3/4] Add .circleci/config.yml --- .circleci/config.yml | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d68fd77f5..dc7779388 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,24 +8,35 @@ jobs: - run: name: Install hadolint command: | - curl -Lo /usr/local/bin/hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64 - chmod +x /usr/local/bin/hadolint + mkdir -p ~/bin + curl -Lo ~/bin/hadolint https://github.com/hadolint/hadolint/releases/latest/download/hadolint-Linux-x86_64 + chmod +x ~/bin/hadolint + sudo mv ~/bin/hadolint /usr/local/bin/hadolint - run: name: Run hadolint on Dockerfile command: hadolint Dockerfile - build-app-karsajobs-ui: + test-app: docker: - - image: circleci/node:14 + - image: circleci/golang:1.16 + steps: + - checkout + - run: + name: Run unit tests + command: go test -v -short --count=1 $(go list ./...) + + build-app-karsajobs: + docker: + - image: circleci/golang:1.16 steps: - checkout - run: - name: Build and push Docker image for karsajobs-ui + name: Build and push Docker image command: | - # Build your karsajobs-ui application - docker build -t ghcr.io/afrinaldipdg/karsajobs-ui:${CIRCLE_SHA1} . + # Build your Go application + docker build -t ghcr.io/afrinaldipdg/karsajobs-circleci:v1 . docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN - docker push ghcr.io/afrinaldipdg/karsajobs-ui:${CIRCLE_SHA1} + docker push ghcr.io/afrinaldipdg/karsajobs-circleci:v1 workflows: version: 2 @@ -35,9 +46,14 @@ workflows: filters: branches: only: - - karsajobs-ui - - build-app-karsajobs-ui: + - karsajobs + - test-app: + filters: + branches: + only: + - karsajobs + - build-app-karsajobs: filters: branches: only: - - karsajobs-ui \ No newline at end of file + - karsajobs From 307ff2b1931254e01ef8c47a758214a34645eba3 Mon Sep 17 00:00:00 2001 From: afrinaldipdg <107689282+afrinaldipdg@users.noreply.github.com> Date: Sat, 21 Oct 2023 18:38:19 +0700 Subject: [PATCH 4/4] Add .circleci/config.yml --- .circleci/config.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dc7779388..cfc4532a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,9 +2,12 @@ version: 2.1 jobs: lint-dockerfile: docker: - - image: circleci/golang:1.16 + - image: circleci/golang:1.16-buster steps: - checkout + - run: + name: Install Git + command: sudo apt-get update && sudo apt-get install git -y - run: name: Install hadolint command: | @@ -18,7 +21,7 @@ jobs: test-app: docker: - - image: circleci/golang:1.16 + - image: circleci/golang:1.16-buster steps: - checkout - run: @@ -27,15 +30,17 @@ jobs: build-app-karsajobs: docker: - - image: circleci/golang:1.16 + - image: circleci/golang:1.16-buster steps: - - checkout + - checkout # Ganti dengan versi Docker yang sesuai + - setup_remote_docker: # Ini akan memungkinkan Anda untuk menggunakan Docker dalam Docker (DinD) + version: 1.16-buster # Ganti dengan versi Docker yang sesuai - run: name: Build and push Docker image command: | # Build your Go application docker build -t ghcr.io/afrinaldipdg/karsajobs-circleci:v1 . - docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN + cat ~/token.txt | docker login --username afrinaldipdg --password-stdin ghcr.io docker push ghcr.io/afrinaldipdg/karsajobs-circleci:v1 workflows: