Skip to content

Commit

Permalink
Make all services use common action
Browse files Browse the repository at this point in the history
  • Loading branch information
alik-agaev committed Nov 13, 2024
1 parent dcca67e commit 09a749b
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 98 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/_docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ on:
service-name:
required: true
type: string
docker-context-path:
required: false
type: string
dockerfile-path:
required: false
type: string
secrets:
ARM_RUNNER_HOSTNAME:
required: true
Expand Down Expand Up @@ -71,15 +77,15 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.service-name }}
file: '${{ inputs.service-name }}/Dockerfile'
context: ${{ inputs.docker-context-path || format('{0}/Dockerfile', inputs.service-name) }}
file: ${{ inputs.dockerfile-path || format('{0}/Dockerfile', inputs.service-name) }}
build-contexts: |
proto=proto
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
platforms: |
linux/amd64
linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.setup.outputs.docker-labels }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}:build-cache,mode=max', env.IMAGE_NAME) || '' }}
59 changes: 8 additions & 51 deletions .github/workflows/bens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,64 +122,21 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 60
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.regex.outputs.group2 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/bens\/(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: "blockscout-ens"
file: "blockscout-ens/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) || '' }}
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: blockscout-ens
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

publish_types_package:
name: Publish types package
uses: './.github/workflows/npm-publisher.yml'
needs: push
if: needs.push.outputs.semver != ''
if: needs.push.outputs.tag-value != ''
secrets: inherit
with:
version: ${{ needs.push.outputs.semver }}
version: ${{ needs.push.outputs.tag-value }}
project_name: blockscout-ens

push-swagger:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/da-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: da-indexer
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/eth-bytecode-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: eth-bytecode-db
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/multichain-aggregator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: multichain-aggregator
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
52 changes: 8 additions & 44 deletions .github/workflows/multichain-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,47 +96,11 @@ 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\/multichain-search\/(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: "multichain-search/backend"
file: "multichain-search/backend/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: multichain-search
secrets:
docker-context-path: "multichain-search/backend"
dockerfile-path: "multichain-search/backend/Dockerfile"
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}
3 changes: 3 additions & 0 deletions .github/workflows/proxy-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: proxy-verifier
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/sig-provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: sig-provider
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}


push-swagger:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/smart-contract-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: smart-contract-verifier
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: stats
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

publish_types_package:
name: Publish types package
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/stylus-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: stylus-verifier
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}
3 changes: 3 additions & 0 deletions .github/workflows/user-ops-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: user-ops-indexer
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/visualizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: visualizer
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

publish_types_package:
name: Publish types package
Expand Down

0 comments on commit 09a749b

Please sign in to comment.