From fa9a91bb96140e40c9244460cc0eee9e1547c491 Mon Sep 17 00:00:00 2001 From: kw1knode Date: Thu, 31 Oct 2024 00:15:14 -0700 Subject: [PATCH 1/2] add ci/cd --- .github/workflows/build.yaml | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..71a0bd0 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,61 @@ + +name: Docker Build and Push + +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + +env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + IMAGE_NAME: evm-loadbalancer + +jobs: + docker: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all tags and branches + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=raw,value=latest + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILDKIT_INLINE_CACHE=1 \ No newline at end of file From 3ebcafb0e4e946708bc187654ceef3af1892e73b Mon Sep 17 00:00:00 2001 From: kw1knode Date: Thu, 31 Oct 2024 00:36:37 -0700 Subject: [PATCH 2/2] moar speed, simple. --- .github/workflows/build.yaml | 39 ++++++++++-------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 71a0bd0..6354f4b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,47 +1,32 @@ - name: Docker Build and Push on: push: tags: - - 'v*.*.*' + - 'v*' workflow_dispatch: + inputs: + tag: + description: 'Tag to build (e.g., v1.2.0)' + required: true + type: string env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} IMAGE_NAME: evm-loadbalancer jobs: - docker: + build: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 0 # Fetch all history for all tags and branches - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - cache: true + ref: ${{ github.event.inputs.tag || github.ref }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - with: - platforms: linux/amd64,linux/arm64 - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }} - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=raw,value=latest - - name: Login to Docker Hub uses: docker/login-action@v3 with: @@ -54,8 +39,6 @@ jobs: context: . platforms: linux/amd64,linux/arm64 push: true - tags: ${{ steps.meta.outputs.tags }} - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - BUILDKIT_INLINE_CACHE=1 \ No newline at end of file + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.event.inputs.tag || github.ref_name }} + ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest \ No newline at end of file