Skip to content

Commit

Permalink
[workflow] Update services to reuse docker workflow (#946)
Browse files Browse the repository at this point in the history
* da-indexer
* eth-bytecode-db
* proxy-verifier
* scoutcloud
* sig-provider
* smart-contract-verifier
* smart-guessr
* stats
* user-ops-indexer
  • Loading branch information
rimrakhimov authored Jun 26, 2024
1 parent fc19980 commit 18f48d6
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 450 deletions.
55 changes: 6 additions & 49 deletions .github/workflows/da-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ on:
- da-indexer/**
- .github/workflows/da-indexer.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml
pull_request:
paths:
- da-indexer/**
- .github/workflows/da-indexer.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml

name: Test, lint and docker (da-indexer)

env:
REGISTRY: ghcr.io
IMAGE_NAME: blockscout/da-indexer

defaults:
run:
working-directory: da-indexer
Expand Down Expand Up @@ -107,7 +105,7 @@ jobs:
- name: cargo clippy
run: cargo clippy --all --all-targets --all-features -- -D warnings

push:
docker:
name: Docker build and docker push
needs:
- test
Expand All @@ -116,47 +114,6 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/da-indexer\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
context: "da-indexer"
file: "da-indexer/Dockerfile"
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}

uses: ./.github/workflows/docker-build-push.yml
with:
service-name: da-indexer
55 changes: 6 additions & 49 deletions .github/workflows/eth-bytecode-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ on:
- eth-bytecode-db/**
- .github/workflows/eth-bytecode-db.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml
pull_request:
paths:
- eth-bytecode-db/**
- .github/workflows/eth-bytecode-db.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml

name: Test, lint and docker (eth-bytecode-db)

env:
REGISTRY: ghcr.io
IMAGE_NAME: blockscout/eth-bytecode-db

defaults:
run:
working-directory: eth-bytecode-db
Expand Down Expand Up @@ -119,7 +117,7 @@ jobs:
- name: cargo clippy
run: cargo clippy --all --all-targets --all-features -- -D warnings

push:
docker:
name: Docker build and docker push
needs:
- test
Expand All @@ -128,47 +126,6 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/eth-bytecode-db\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "eth-bytecode-db"
file: "eth-bytecode-db/eth-bytecode-db-server/Dockerfile"
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}
uses: ./.github/workflows/docker-build-push.yml
with:
service-name: eth-bytecode-db
55 changes: 6 additions & 49 deletions .github/workflows/proxy-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ on:
- proxy-verifier/**
- .github/workflows/proxy-verifier.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml
pull_request:
paths:
- proxy-verifier/**
- .github/workflows/proxy-verifier.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml

name: Test, lint and docker (proxy-verifier)

env:
REGISTRY: ghcr.io
IMAGE_NAME: blockscout/proxy-verifier

defaults:
run:
working-directory: proxy-verifier
Expand Down Expand Up @@ -89,7 +87,7 @@ jobs:
- name: cargo clippy
run: cargo clippy --all --all-targets --all-features -- -D warnings

push:
docker:
name: Docker build and docker push
needs:
- test
Expand All @@ -98,47 +96,6 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/proxy-verifier\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "proxy-verifier"
file: "proxy-verifier/Dockerfile"
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}

uses: ./.github/workflows/docker-build-push.yml
with:
service-name: proxy-verifier
57 changes: 7 additions & 50 deletions .github/workflows/scoutcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ on:
- scoutcloud/**
- .github/workflows/scoutcloud.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml
pull_request:
paths:
- scoutcloud/**
- .github/workflows/scoutcloud.yml
- .github/actions/deps/**
- .github/workflows/docker-build-push.yml

name: Test, lint and docker (scoutcloud)

env:
REGISTRY: ghcr.io
IMAGE_NAME: blockscout/scoutcloud

defaults:
run:
working-directory: scoutcloud
Expand Down Expand Up @@ -111,7 +109,7 @@ jobs:
- name: cargo clippy
run: cargo clippy --all --all-targets --all-features -- -D warnings

push:
docker:
name: Docker build and docker push
needs:
- test
Expand All @@ -120,54 +118,13 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: ./.github/workflows/docker-build-push.yml
with:
service-name: scoutcloud

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/scoutcloud\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "scoutcloud"
file: "scoutcloud/Dockerfile"
build-contexts: |
proto=proto
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}
deploy_prod:
name: Deploy prod instance
needs: push
needs: docker
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions: write-all
Expand Down
Loading

0 comments on commit 18f48d6

Please sign in to comment.