Skip to content

Commit 809ffa6

Browse files
committed
feat(gh-action): add tag extraction, rename file, add commit msg
1 parent f288bb5 commit 809ffa6

File tree

2 files changed

+116
-59
lines changed

2 files changed

+116
-59
lines changed

.github/workflows/_push_swagger.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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: '[email protected]'
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+
29+
jobs:
30+
copy-swagger:
31+
name: Copy swagger
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Get the current tag, branch, or commit hash
38+
id: git_info
39+
run: |
40+
if [[ "${GITHUB_REF}" =~ refs/tags/${{ inputs.service_name }}/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
41+
version=$(echo "${GITHUB_REF}" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+')
42+
echo "version=${version}" >> $GITHUB_ENV
43+
44+
# If it's the main branch
45+
elif [ "${GITHUB_REF#refs/heads/}" = "main" ]; then
46+
echo "version=main" >> $GITHUB_ENV
47+
48+
# Otherwise, use the first 8 characters of the commit hash
49+
else
50+
echo "version=${GITHUB_SHA:0:8}" >> $GITHUB_ENV
51+
fi
52+
53+
- name: Push swagger to another repo
54+
uses: dmnemec/copy_file_to_another_repo_action@main
55+
env:
56+
API_TOKEN_GITHUB: ${{ secrets.api_token_github }}
57+
with:
58+
source_file: ${{ inputs.swagger_path }}
59+
rename: 'swagger.yaml'
60+
commit_message: '[BOT] [CREATE-SWAGGER] [SKIP-GH-PAGES] create swagger for "${{ inputs.service_name }}" of version ${{ env.version }}'
61+
destination_repo: 'blockscout/swaggers'
62+
destination_folder: "services/${{ inputs.service_name }}/${{ env.version }}"
63+
user_email: ${{ inputs.user_email }}
64+
user_name: ${{ inputs.user_name }}
65+
destination_branch: 'master'

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

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,64 +23,56 @@ defaults:
2323
working-directory: smart-contract-verifier
2424

2525
jobs:
26-
test:
27-
name: Unit, doc and integration tests
28-
runs-on: ubuntu-latest
29-
steps:
30-
- name: Checkout sources
31-
uses: actions/checkout@v4
26+
# test:
27+
# name: Unit, doc and integration tests
28+
# runs-on: ubuntu-latest
29+
# steps:
30+
# - name: Checkout sources
31+
# uses: actions/checkout@v4
32+
#
33+
# - name: Setup
34+
# uses: ./.github/actions/setup
35+
# with:
36+
# working-directory: smart-contract-verifier
37+
#
38+
# - name: Unit tests
39+
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
40+
# if: success() || failure()
41+
#
42+
# - name: Doc tests
43+
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --doc -- --skip proto
44+
# if: success() || failure()
45+
#
46+
# - name: Integration tests
47+
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --test '*' -- --nocapture
48+
# if: success() || failure()
49+
#
50+
# lint:
51+
# name: Linting
52+
# uses: ./.github/workflows/_linting.yml
53+
# with:
54+
# working-directory: smart-contract-verifier
55+
#
56+
# docker:
57+
# name: Docker build and docker push
58+
# needs:
59+
# - test
60+
# - lint
61+
# if: |
62+
# always() &&
63+
# (needs.test.result == 'success' || needs.test.result == 'cancelled') &&
64+
# (needs.lint.result == 'success' || needs.lint.result == 'cancelled')
65+
# uses: ./.github/workflows/_docker-build-push.yml
66+
# with:
67+
# service-name: smart-contract-verifier
3268

33-
- name: Setup
34-
uses: ./.github/actions/setup
35-
with:
36-
working-directory: smart-contract-verifier
37-
38-
- name: Unit tests
39-
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture
40-
if: success() || failure()
41-
42-
- name: Doc tests
43-
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --doc -- --skip proto
44-
if: success() || failure()
45-
46-
- name: Integration tests
47-
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --test '*' -- --nocapture
48-
if: success() || failure()
49-
50-
lint:
51-
name: Linting
52-
uses: ./.github/workflows/_linting.yml
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
5372
with:
54-
working-directory: smart-contract-verifier
55-
56-
docker:
57-
name: Docker build and docker push
58-
needs:
59-
- test
60-
- lint
61-
if: |
62-
always() &&
63-
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
64-
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
65-
uses: ./.github/workflows/_docker-build-push.yml
66-
with:
67-
service-name: smart-contract-verifier
68-
69-
copy-swagger:
70-
name: Copy swagger
71-
runs-on: ubuntu-latest
72-
steps:
73-
- name: Checkout
74-
uses: actions/checkout@v4
75-
76-
- name: Pushes
77-
uses: dmnemec/copy_file_to_another_repo_action@main
78-
env:
79-
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
80-
with:
81-
source_file: 'smart-contract-verifier/smart-contract-verifier-proto/swagger/v2/smart-contract-verifier.swagger.yaml'
82-
destination_repo: 'blockscout/swaggers'
83-
destination_folder: 'services/smart-contract-verifier'
84-
user_email: '[email protected] '
85-
user_name: 'rimrakhimov'
86-
destination_branch: 'master'
73+
user_name: 'blockscout-bot'
74+
user_email: '[email protected]'
75+
service_name: 'smart-contract-verifier'
76+
swagger_path: 'smart-contract-verifier/smart-contract-verifier-proto/swagger/v2/smart-contract-verifier.swagger.yaml'
77+
secrets:
78+
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}

0 commit comments

Comments
 (0)