Skip to content

Commit 6f1cf03

Browse files
Setup workflows to copy swagger files (#865)
* Copy swagger job for smart-contract-verifier * Update directory name not to contain file name * feat(gh-action): add tag extraction, rename file, add commit msg --------- Co-authored-by: sevenzing <41516657+sevenzing@users.noreply.github.com>
1 parent 040868d commit 6f1cf03

File tree

10 files changed

+178
-1
lines changed

10 files changed

+178
-1
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Copy Swagger
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
api_token_github:
7+
description: 'GitHub API token'
8+
required: true
9+
inputs:
10+
user_name:
11+
description: 'Commit username'
12+
required: false
13+
default: 'blockscout-bot'
14+
type: string
15+
user_email:
16+
description: 'Commit user email'
17+
required: false
18+
type: string
19+
default: 'bot@blockscout.com'
20+
service_name:
21+
description: 'Service name (e.g., smart-contract-verifier)'
22+
required: true
23+
type: string
24+
swagger_path:
25+
description: 'Path to the swagger file'
26+
required: true
27+
type: string
28+
workflow_dispatch:
29+
inputs:
30+
user_name:
31+
description: 'Commit username'
32+
required: false
33+
default: 'blockscout-bot'
34+
type: string
35+
user_email:
36+
description: 'Commit user email'
37+
required: false
38+
default: 'bot@blockscout.com'
39+
type: string
40+
service_name:
41+
description: 'Service name (e.g., smart-contract-verifier)'
42+
required: true
43+
type: string
44+
swagger_path:
45+
description: 'Path to the swagger file'
46+
required: true
47+
type: string
48+
version:
49+
description: 'Version to set if manually triggered'
50+
required: true
51+
type: string
52+
53+
jobs:
54+
copy-swagger:
55+
name: Copy swagger
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
61+
- name: Get the current tag, branch, or commit hash
62+
id: git_info
63+
run: |
64+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
65+
echo "version=${{ inputs.version }}" >> $GITHUB_ENV
66+
else
67+
if [[ "${GITHUB_REF}" =~ refs/tags/${{ inputs.service_name }}/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
68+
version=$(echo "${GITHUB_REF}" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+')
69+
echo "version=${version}" >> $GITHUB_ENV
70+
71+
# If it's the main branch
72+
elif [ "${GITHUB_REF#refs/heads/}" = "main" ]; then
73+
echo "version=main" >> $GITHUB_ENV
74+
75+
# Otherwise, use the first 8 characters of the commit hash
76+
else
77+
echo "version=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
78+
fi
79+
fi
80+
echo "version=${version}"
81+
82+
- name: Push swagger to another repo
83+
uses: dmnemec/copy_file_to_another_repo_action@main
84+
env:
85+
API_TOKEN_GITHUB: ${{ secrets.api_token_github || secrets.BLOCKSCOUT_BOT_TOKEN }}
86+
with:
87+
source_file: ${{ inputs.swagger_path }}
88+
rename: 'swagger.yaml'
89+
commit_message: '[BOT] [CREATE-SWAGGER] [SKIP-GH-PAGES] create swagger for "${{ inputs.service_name }}" of version ${{ env.version }}'
90+
destination_repo: 'blockscout/swaggers'
91+
destination_folder: "services/${{ inputs.service_name }}/${{ env.version }}"
92+
user_email: ${{ inputs.user_email }}
93+
user_name: ${{ inputs.user_name }}
94+
destination_branch: 'master'

.github/workflows/bens.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,13 @@ jobs:
175175
secrets: inherit
176176
with:
177177
version: ${{ needs.push.outputs.semver }}
178-
project_name: blockscout-ens
178+
project_name: blockscout-ens
179+
180+
push-swagger:
181+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
182+
uses: ./.github/workflows/_push_swagger.yml
183+
with:
184+
service_name: 'bens'
185+
swagger_path: 'blockscout-ens/bens-proto/swagger/bens.swagger.yaml'
186+
secrets:
187+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/da-indexer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,12 @@ jobs:
8383
uses: ./.github/workflows/_docker-build-push.yml
8484
with:
8585
service-name: da-indexer
86+
87+
push-swagger:
88+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
89+
uses: ./.github/workflows/_push_swagger.yml
90+
with:
91+
service_name: 'da-indexer'
92+
swagger_path: 'da-indexer/da-indexer-proto/swagger/v1/da-indexer.swagger.yaml'
93+
secrets:
94+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/eth-bytecode-db.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,12 @@ jobs:
9595
uses: ./.github/workflows/_docker-build-push.yml
9696
with:
9797
service-name: eth-bytecode-db
98+
99+
push-swagger:
100+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
101+
uses: ./.github/workflows/_push_swagger.yml
102+
with:
103+
service_name: 'eth-bytecode-db'
104+
swagger_path: 'eth-bytecode-db/eth-bytecode-db-proto/swagger/v2/eth-bytecode-db.swagger.yaml'
105+
secrets:
106+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/proxy-verifier.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,12 @@ jobs:
6565
uses: ./.github/workflows/_docker-build-push.yml
6666
with:
6767
service-name: proxy-verifier
68+
69+
push-swagger:
70+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
71+
uses: ./.github/workflows/_push_swagger.yml
72+
with:
73+
service_name: 'proxy-verifier'
74+
swagger_path: 'proxy-verifier/proxy-verifier-proto/swagger/v1/proxy-verifier.swagger.yaml'
75+
secrets:
76+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/sig-provider.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ jobs:
6565
uses: ./.github/workflows/_docker-build-push.yml
6666
with:
6767
service-name: sig-provider
68+
69+
70+
push-swagger:
71+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
72+
uses: ./.github/workflows/_push_swagger.yml
73+
with:
74+
service_name: 'sig-provider'
75+
swagger_path: 'sig-provider/sig-provider-proto/swagger/sig-provider.swagger.yaml'
76+
secrets:
77+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/smart-contract-verifier.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,12 @@ jobs:
6565
uses: ./.github/workflows/_docker-build-push.yml
6666
with:
6767
service-name: smart-contract-verifier
68+
69+
push-swagger:
70+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
71+
uses: ./.github/workflows/_push_swagger.yml
72+
with:
73+
service_name: 'smart-contract-verifier'
74+
swagger_path: 'smart-contract-verifier/smart-contract-verifier-proto/swagger/v2/smart-contract-verifier.swagger.yaml'
75+
secrets:
76+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/stats.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,13 @@ jobs:
9494
with:
9595
version: ${{ needs.docker.outputs.tag-value }}
9696
project_name: stats
97+
98+
99+
push-swagger:
100+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
101+
uses: ./.github/workflows/_push_swagger.yml
102+
with:
103+
service_name: 'stats'
104+
swagger_path: 'stats/stats-proto/swagger/stats.swagger.yaml'
105+
secrets:
106+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/user-ops-indexer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,12 @@ jobs:
8181
uses: ./.github/workflows/_docker-build-push.yml
8282
with:
8383
service-name: user-ops-indexer
84+
85+
push-swagger:
86+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
87+
uses: ./.github/workflows/_push_swagger.yml
88+
with:
89+
service_name: 'user-ops-indexer'
90+
swagger_path: 'user-ops-indexer/user-ops-indexer-proto/swagger/user-ops-indexer.swagger.yaml'
91+
secrets:
92+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

.github/workflows/visualizer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,12 @@ jobs:
8484
with:
8585
version: ${{ needs.docker.outputs.tag-value }}
8686
project_name: visualizer
87+
88+
push-swagger:
89+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
90+
uses: ./.github/workflows/_push_swagger.yml
91+
with:
92+
service_name: 'visualizer'
93+
swagger_path: 'visualizer/visualizer-proto/swagger/visualizer.swagger.yaml'
94+
secrets:
95+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

0 commit comments

Comments
 (0)