|
| 1 | +name: 'KyberSwap Interface CI' |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ci-workflow-${{ github.ref }}-${{ github.event_name }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +env: |
| 13 | + SERVICE: kyberswap-interface |
| 14 | + |
| 15 | +jobs: |
| 16 | + prepare: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + current_branch: ${{ steps.current_branch.outputs.value }} |
| 20 | + head_sha: ${{ steps.head_sha.outputs.value }} |
| 21 | + image_name: 'asia.gcr.io/kyber-operation/core/${{ env.SERVICE }}' |
| 22 | + image_tag: ${{ steps.get_tag.outputs.image_tag }} |
| 23 | + image_tag_stg: ${{ steps.get_tag.outputs.image_tag_stg }} |
| 24 | + branch_tag: ${{ steps.get_tag.outputs.branch_tag }} |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 |
| 28 | + |
| 29 | + - name: Extract branch |
| 30 | + shell: bash |
| 31 | + id: current_branch |
| 32 | + run: | |
| 33 | + if [[ ! "${{ github.ref }}" = "refs/tags/"* ]]; then |
| 34 | + if [[ "${{ github.event_name }}" = "pull_request" ]]; then |
| 35 | + HEAD_REF=$(printf "%q" "${{ github.head_ref }}") |
| 36 | + HEAD_REF=${HEAD_REF/refs\/heads\//} |
| 37 | + BRANCH=$HEAD_REF |
| 38 | + else |
| 39 | + REF=$(printf "%q" "${{ github.ref }}") |
| 40 | + REF_BRANCH=${REF/refs\/pull\//} |
| 41 | + REF_BRANCH=${REF_BRANCH/refs\/heads\//} |
| 42 | + BRANCH=$REF_BRANCH |
| 43 | + fi |
| 44 | + else |
| 45 | + REF=$(printf "%q" "${{ github.ref }}") |
| 46 | + REF_BRANCH=${REF/refs\/tags\//} |
| 47 | + BRANCH=$REF_BRANCH |
| 48 | + fi |
| 49 | + echo "::set-output name=value::$BRANCH" |
| 50 | +
|
| 51 | + - name: Extract GitHub HEAD SHA |
| 52 | + id: head_sha |
| 53 | + run: echo "::set-output name=value::$(git rev-parse HEAD)" |
| 54 | + |
| 55 | + - name: Get Docker image tag |
| 56 | + id: get_tag |
| 57 | + env: |
| 58 | + CURRENT_BRANCH: ${{ steps.current_branch.outputs.value }} |
| 59 | + run: | |
| 60 | + short_sha="$(git rev-parse --short HEAD)" |
| 61 | + branch_tag="$(echo "$CURRENT_BRANCH" | sed 's/[^a-zA-Z0-9]/-/g' | sed 's/--*/-/g' | sed 's/-$//g')" |
| 62 | + echo "::set-output name=image_tag::$branch_tag-$short_sha" |
| 63 | + echo "::set-output name=image_tag_stg::$branch_tag-stg-build-$short_sha" |
| 64 | + echo "::set-output name=branch_tag::$branch_tag-$short_sha" |
| 65 | +
|
| 66 | + lint: |
| 67 | + runs-on: ubuntu-22.04 |
| 68 | + needs: |
| 69 | + - prepare |
| 70 | + steps: |
| 71 | + - name: Checkout |
| 72 | + uses: actions/checkout@v4 |
| 73 | + |
| 74 | + - uses: pnpm/action-setup@v4 |
| 75 | + name: Install pnpm |
| 76 | + with: |
| 77 | + version: 8.9.2 |
| 78 | + run_install: false |
| 79 | + |
| 80 | + - name: Set up Node.js |
| 81 | + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0 |
| 82 | + with: |
| 83 | + node-version: 21.0.0 |
| 84 | + registry-url: 'https://npm.pkg.github.com' |
| 85 | + scope: '@kybernetwork' |
| 86 | + token: ${{ secrets.GH_PAT }} |
| 87 | + cache: 'pnpm' |
| 88 | + |
| 89 | + - name: Install dependencies |
| 90 | + run: pnpm install |
| 91 | + |
| 92 | + - name: Build packages |
| 93 | + run: | |
| 94 | + pnpm --parallel -r --filter "@kyber/svgr-esbuild-plugin" --filter "@kyber/ui" build |
| 95 | + pnpm --filter "@kyberswap/liquidity-chart" build |
| 96 | +
|
| 97 | + - name: Run lint |
| 98 | + run: pnpm lint && pnpm type-check |
| 99 | + |
0 commit comments