Skip to content

Commit

Permalink
feat(gh-action): add tag extraction, rename file, add commit msg
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenzing committed Sep 4, 2024
1 parent f288bb5 commit 5979345
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 48 deletions.
Empty file.
115 changes: 67 additions & 48 deletions .github/workflows/smart-contract-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,48 @@ 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

- 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
# 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

copy-swagger:
name: Copy swagger
Expand All @@ -73,14 +73,33 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Pushes
- name: Get the current tag, branch, or commit hash
id: git_info
run: |
# Extract the tag if it matches the pattern refs/tags/smart-contract-verifier/v1.2.3
if [[ "${GITHUB_REF}" =~ refs/tags/smart-contract-verifier/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
- name: Push swagger to another repo
uses: dmnemec/copy_file_to_another_repo_action@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
API_TOKEN_GITHUB: ${{ secrets.BLOCKSCOUT_BOT_TOKEN }}
with:
source_file: 'smart-contract-verifier/smart-contract-verifier-proto/swagger/v2/smart-contract-verifier.swagger.yaml'
rename: 'swagger.yaml'
commit_message: '[BOT] [CREATE-SWAGGER] [SKIP-GH-PAGES] create swagger for "smart-contract-verifier" of version ${{ env.version }}'
destination_repo: 'blockscout/swaggers'
destination_folder: 'services/smart-contract-verifier'
user_email: 'rimrakhimov@gmail.com '
user_name: 'rimrakhimov'
destination_branch: 'master'
destination_folder: "services/smart-contract-verifier/${{ env.version }}"
user_email: 'bot@blockscout.com'
user_name: 'blockscout-bot'
destination_branch: 'master'

0 comments on commit 5979345

Please sign in to comment.