From 593b015a90ab512227323dcdbddcd5d6584f6e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20K=C5=91szegi?= <43576573+krisztiankoszegi@users.noreply.github.com> Date: Thu, 15 Jul 2021 15:17:45 +0200 Subject: [PATCH 1/3] Create gha workflow --- .github/workflows/workflow.yml | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/workflow.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..6c3197d --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,78 @@ +name: build_and_test + +on: + pull_request: + push: + branches: + - main + +env: + DEPLOY_REGISTRY_URL: ${{ secrets.DEPLOY_REGISTRY_URL }} + ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + +jobs: + build: + name: build + runs-on: + - self-hosted + - production + container: docker-hub.tw.ee/golang + defaults: + run: + working-directory: ~/actions-exporter + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Attach workspace + uses: actions/download-artifact@v2 + with: + name: shared_workspace + path: ~/actions-exporter + + - name: Format + run: make fmt + + - name: Tests + run: make test + + - name: Build + run: make build + + - name: Persist to workspace + uses: actions/upload-artifact@v2 + with: + path: ./* + name: shared_workspace + + publish: + name: publish + runs-on: + - self-hosted + - production + container: docker.tw.ee/k8s-deployer:3.8 + defaults: + run: + working-directory: ~/actions-exporter + if: github.ref == 'refs/heads/m' && github.ref == 'refs/heads/a' && github.ref == 'refs/heads/i' && github.ref == 'refs/heads/n' + needs: + - build + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Attach workspace + uses: actions/download-artifact@v2 + with: + name: shared_workspace + path: ~/actions-exporter + + - name: Build and Push Image + run: .github/scripts/build_and_publish.sh From 1dafba78cf1071ddb2f214d5249b4d85152eb52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20K=C5=91szegi?= <43576573+krisztiankoszegi@users.noreply.github.com> Date: Thu, 15 Jul 2021 15:20:10 +0200 Subject: [PATCH 2/3] Create build_and_publish.sh --- .github/scripts/build_and_publish.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/scripts/build_and_publish.sh diff --git a/.github/scripts/build_and_publish.sh b/.github/scripts/build_and_publish.sh new file mode 100644 index 0000000..bd17a0d --- /dev/null +++ b/.github/scripts/build_and_publish.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +REGISTRY_URL=docker.tw.ee +COMMIT=${CIRCLE_SHA1:0:8} +TAG=v0.2.0-${COMMIT} + +echo "Building images" + +docker build --pull -t "${REGISTRY_URL}/actions-api-exporter:${TAG}" . + +echo "${DEPLOY_REGISTRY_PASSWORD}" | docker login ${REGISTRY_URL} --username "${DEPLOY_REGISTRY_USERNAME}" --password-stdin + +if [ "$CIRCLE_BRANCH" == "main" ] +then + echo "Pushing image.." + docker push "${REGISTRY_URL}/actions-api-exporter:${TAG}" +fi + +echo "done." From 40081ec9a5c03f5100dd7d1f65b640ddc2c39450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kriszti=C3=A1n=20K=C5=91szegi?= <43576573+krisztiankoszegi@users.noreply.github.com> Date: Thu, 15 Jul 2021 15:21:02 +0200 Subject: [PATCH 3/3] Delete .circleci directory --- .circleci/build_and_publish.sh | 19 ------------- .circleci/config.yml | 50 ---------------------------------- 2 files changed, 69 deletions(-) delete mode 100755 .circleci/build_and_publish.sh delete mode 100644 .circleci/config.yml diff --git a/.circleci/build_and_publish.sh b/.circleci/build_and_publish.sh deleted file mode 100755 index bd17a0d..0000000 --- a/.circleci/build_and_publish.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -REGISTRY_URL=docker.tw.ee -COMMIT=${CIRCLE_SHA1:0:8} -TAG=v0.2.0-${COMMIT} - -echo "Building images" - -docker build --pull -t "${REGISTRY_URL}/actions-api-exporter:${TAG}" . - -echo "${DEPLOY_REGISTRY_PASSWORD}" | docker login ${REGISTRY_URL} --username "${DEPLOY_REGISTRY_USERNAME}" --password-stdin - -if [ "$CIRCLE_BRANCH" == "main" ] -then - echo "Pushing image.." - docker push "${REGISTRY_URL}/actions-api-exporter:${TAG}" -fi - -echo "done." diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 278597d..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,50 +0,0 @@ -version: 2 -jobs: - build: - working_directory: ~/actions-exporter - docker: - - image: docker-hub.tw.ee/golang - steps: - - checkout - - attach_workspace: - at: ~/actions-exporter - - run: - name: Format - command: make fmt - - run: - name: Tests - command: make test - - run: - name: Build - command: make build - - persist_to_workspace: - root: . - paths: - - '*' - - publish: - working_directory: ~/actions-exporter - docker: - - image: docker.tw.ee/k8s-deployer:3.8 - steps: - - checkout - - setup_remote_docker - - attach_workspace: - at: ~/actions-exporter - - run: - name: Build and Push Image - command: .circleci/build_and_publish.sh - -workflows: - version: 2 - build_and_test: - jobs: - - build: - context: artifactory-deploy-docker - - publish: - context: artifactory-deploy-docker - requires: - - build - filters: - branches: - only: main