-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gh-action): add tag extraction, rename file, add commit msg
- Loading branch information
Showing
2 changed files
with
145 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Copy Swagger | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
api_token_github: | ||
description: 'GitHub API token' | ||
required: true | ||
inputs: | ||
user_name: | ||
description: 'Commit username' | ||
required: false | ||
default: 'blockscout-bot' | ||
type: string | ||
user_email: | ||
description: 'Commit user email' | ||
required: false | ||
type: string | ||
default: '[email protected]' | ||
service_name: | ||
description: 'Service name (e.g., smart-contract-verifier)' | ||
required: true | ||
type: string | ||
swagger_path: | ||
description: 'Path to the swagger file' | ||
required: true | ||
type: string | ||
workflow_dispatch: | ||
inputs: | ||
user_name: | ||
description: 'Commit username' | ||
required: false | ||
default: 'blockscout-bot' | ||
type: string | ||
user_email: | ||
description: 'Commit user email' | ||
required: false | ||
default: '[email protected]' | ||
type: string | ||
service_name: | ||
description: 'Service name (e.g., smart-contract-verifier)' | ||
required: true | ||
type: string | ||
swagger_path: | ||
description: 'Path to the swagger file' | ||
required: true | ||
type: string | ||
version: | ||
description: 'Version to set if manually triggered' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
copy-swagger: | ||
name: Copy swagger | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get the current tag, branch, or commit hash | ||
id: git_info | ||
run: | | ||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
echo "version=${{ inputs.version }}" >> $GITHUB_ENV | ||
else | ||
if [[ "${GITHUB_REF}" =~ refs/tags/${{ inputs.service_name }}/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
version=$(echo "${GITHUB_REF}" | grep -o 'v[0-9]\+\.[0-9]\+\.[0-9]\+') | ||
echo "version=${version}" >> $GITHUB_ENV | ||
# If it's the main branch | ||
elif [ "${GITHUB_REF#refs/heads/}" = "main" ]; then | ||
echo "version=main" >> $GITHUB_ENV | ||
# Otherwise, use the first 8 characters of the commit hash | ||
else | ||
echo "version=${GITHUB_SHA:0:8}" >> $GITHUB_ENV | ||
fi | ||
fi | ||
echo "version=${version}" | ||
- name: Push swagger to another repo | ||
uses: dmnemec/copy_file_to_another_repo_action@main | ||
env: | ||
API_TOKEN_GITHUB: ${{ secrets.api_token_github || secrets.BLOCKSCOUT_BOT_TOKEN }} | ||
with: | ||
source_file: ${{ inputs.swagger_path }} | ||
rename: 'swagger.yaml' | ||
commit_message: '[BOT] [CREATE-SWAGGER] [SKIP-GH-PAGES] create swagger for "${{ inputs.service_name }}" of version ${{ env.version }}' | ||
destination_repo: 'blockscout/swaggers' | ||
destination_folder: "services/${{ inputs.service_name }}/${{ env.version }}" | ||
user_email: ${{ inputs.user_email }} | ||
user_name: ${{ inputs.user_name }} | ||
destination_branch: 'master' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,64 +23,56 @@ defaults: | |
working-directory: smart-contract-verifier | ||
|
||
jobs: | ||
test: | ||
name: Unit, doc and integration tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v4 | ||
# test: | ||
# name: Unit, doc and integration tests | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout sources | ||
# uses: actions/checkout@v4 | ||
# | ||
# - name: Setup | ||
# uses: ./.github/actions/setup | ||
# with: | ||
# working-directory: smart-contract-verifier | ||
# | ||
# - name: Unit tests | ||
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture | ||
# if: success() || failure() | ||
# | ||
# - name: Doc tests | ||
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --doc -- --skip proto | ||
# if: success() || failure() | ||
# | ||
# - name: Integration tests | ||
# run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --test '*' -- --nocapture | ||
# if: success() || failure() | ||
# | ||
# lint: | ||
# name: Linting | ||
# uses: ./.github/workflows/_linting.yml | ||
# with: | ||
# working-directory: smart-contract-verifier | ||
# | ||
# docker: | ||
# name: Docker build and docker push | ||
# needs: | ||
# - test | ||
# - lint | ||
# if: | | ||
# always() && | ||
# (needs.test.result == 'success' || needs.test.result == 'cancelled') && | ||
# (needs.lint.result == 'success' || needs.lint.result == 'cancelled') | ||
# uses: ./.github/workflows/_docker-build-push.yml | ||
# with: | ||
# service-name: smart-contract-verifier | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
with: | ||
working-directory: smart-contract-verifier | ||
|
||
- name: Unit tests | ||
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --lib --bins -- --nocapture | ||
if: success() || failure() | ||
|
||
- name: Doc tests | ||
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --all-features --doc -- --skip proto | ||
if: success() || failure() | ||
|
||
- name: Integration tests | ||
run: RUST_BACKTRACE=1 RUST_LOG=info cargo test --locked --workspace --test '*' -- --nocapture | ||
if: success() || failure() | ||
|
||
lint: | ||
name: Linting | ||
uses: ./.github/workflows/_linting.yml | ||
push-swagger: | ||
# if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')) | ||
uses: ./.github/workflows/push_swagger.yml | ||
with: | ||
working-directory: smart-contract-verifier | ||
|
||
docker: | ||
name: Docker build and docker push | ||
needs: | ||
- test | ||
- lint | ||
if: | | ||
always() && | ||
(needs.test.result == 'success' || needs.test.result == 'cancelled') && | ||
(needs.lint.result == 'success' || needs.lint.result == 'cancelled') | ||
uses: ./.github/workflows/_docker-build-push.yml | ||
with: | ||
service-name: smart-contract-verifier | ||
|
||
copy-swagger: | ||
name: Copy swagger | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Pushes | ||
uses: dmnemec/copy_file_to_another_repo_action@main | ||
env: | ||
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | ||
with: | ||
source_file: 'smart-contract-verifier/smart-contract-verifier-proto/swagger/v2/smart-contract-verifier.swagger.yaml' | ||
destination_repo: 'blockscout/swaggers' | ||
destination_folder: 'services/smart-contract-verifier' | ||
user_email: '[email protected] ' | ||
user_name: 'rimrakhimov' | ||
destination_branch: 'master' | ||
user_name: 'blockscout-bot' | ||
user_email: '[email protected]' | ||
service_name: 'smart-contract-verifier' | ||
swagger_path: 'smart-contract-verifier/smart-contract-verifier-proto/swagger/v2/smart-contract-verifier.swagger.yaml' | ||
secrets: | ||
api_token_github: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }} |