From 5141b122f8f4536bf0e2960e46850c0601fb7fee Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Fri, 9 Aug 2024 16:00:15 -0500 Subject: [PATCH 1/6] Build docker image using github actions --- .github/workflows/build.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..8f2b85e2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: Build Docker Image + +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}-{{ github.event_name }} + cancel-in-progress: true + +jobs: + build-docker-image: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Make docker image + uses: make docker-build + + - name: Retag docker image + uses: docker tag stellar/stellar-etl:${{ github.sha }} stellar/stellar-etl-dev:${{ github.sha }} + + - name: Push docker image + uses: docker push stellar/stellar-etl-dev:${{ github.sha }} From 37fa6a5b92901a8ad38252ecb1743d4796c0e4d7 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Fri, 9 Aug 2024 16:02:34 -0500 Subject: [PATCH 2/6] update update update update update override update --- .github/workflows/build.yml | 17 ++++++++++++----- Makefile | 3 ++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f2b85e2..4001ae8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,11 +20,18 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Make docker image - uses: make docker-build + - name: Add SHORT_SHA env property with commit short sha + run: | + SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7) + echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV + echo "Short SHA: $SHORT_SHA" - - name: Retag docker image - uses: docker tag stellar/stellar-etl:${{ github.sha }} stellar/stellar-etl-dev:${{ github.sha }} + - name: Make docker image + working-directory: . + run: make docker-build + env: + ETLHASH: stellar/stellar-etl-dev:${SHORT_SHA} - name: Push docker image - uses: docker push stellar/stellar-etl-dev:${{ github.sha }} + working-directory: . + run: docker push stellar/stellar-etl-dev:${SHORT_SHA} diff --git a/Makefile b/Makefile index a463e1f1..5a35388b 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ SUDO := $(shell docker version >/dev/null 2>&1 || echo "sudo") # https://github.com/opencontainers/image-spec/blob/master/annotations.md BUILD_DATE := $(shell date -u +%FT%TZ) -ETLHASH=stellar/stellar-etl:$(shell git rev-parse --short HEAD) +DEFAULT_ETLHASH := stellar/stellar-etl:$(shell git rev-parse --short HEAD) +ETLHASH ?= $(DEFAULT_ETLHASH) docker-build: $(SUDO) docker build --platform linux/amd64 --pull --no-cache --label org.opencontainers.image.created="$(BUILD_DATE)" \ From 68fafd9a55dcf4547880627d082091db03b2c906 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Fri, 9 Aug 2024 16:35:43 -0500 Subject: [PATCH 3/6] Pull the right sha use the right sha? --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4001ae8b..97c5459a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Add SHORT_SHA env property with commit short sha run: | - SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7) + SHORT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }}) echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV echo "Short SHA: $SHORT_SHA" From 8e93da36965c27b0a44740a6e33d0317cd840329 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Tue, 20 Aug 2024 12:09:26 -0500 Subject: [PATCH 4/6] Login to dockerhub --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 97c5459a..6c3c2c81 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,12 @@ jobs: env: ETLHASH: stellar/stellar-etl-dev:${SHORT_SHA} + - name: Login to DockerHub + uses: docker/login-action@bb984efc561711aaa26e433c32c3521176eae55b + with: + username: stellardataeng + password: ${{ secrets.DOCKER_CREDS_DEV }} + - name: Push docker image working-directory: . run: docker push stellar/stellar-etl-dev:${SHORT_SHA} From 7d2d49841a69bf7ce80c038fbe1be32b74e6073e Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Tue, 20 Aug 2024 12:20:21 -0500 Subject: [PATCH 5/6] Keep sha length consistent --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6c3c2c81..5550117e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: Add SHORT_SHA env property with commit short sha run: | - SHORT_SHA=$(git rev-parse --short ${{ github.event.pull_request.head.sha }}) + SHORT_SHA=$(git rev-parse --short=9 ${{ github.event.pull_request.head.sha }}) echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV echo "Short SHA: $SHORT_SHA" From af9eaa88b21d5402c9acf720558ff7c50cd38939 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Tue, 20 Aug 2024 12:38:05 -0500 Subject: [PATCH 6/6] Run gh actions manually --- .github/workflows/build.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5550117e..8ebdc3d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,7 @@ name: Build Docker Image on: - push: - branches: - - master - pull_request: - branches: - - master + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}-{{ github.event_name }}