Skip to content

Commit

Permalink
chore: Update cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Oct 21, 2024
1 parent 1a9acaf commit c0ca75f
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 167 deletions.
31 changes: 31 additions & 0 deletions .github/actions/alpha/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: alpha-cicd-trigger-by-comment

inputs:
app-name:
description: 'app name'
required: true

runs:
using: composite
steps:
- name: Install & build
shell: bash
run: |
node .release/scripts/install.js
node common/scripts/install-run-rush.js install -t @bnb-chain/$APP_NAME
node common/scripts/install-run-rush.js build -t @bnb-chain/$APP_NAME
env:
APP_NAME: ${{inputs.app-name}}

- name: Create and publish versions
uses: changesets/action@v1
with:
version: pnpm ci:alpha-version
publish: pnpm ci:publish
commit: 'chore: Update versions'
title: 'chore: Update versions'
cwd: '.release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
46 changes: 46 additions & 0 deletions .github/actions/gh-pages/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: github-pages-cicd

runs:
using: composite
steps:
- name: Creating .env
shell: bash
run: |
cat << EOF > "./apps/canonical-bridge-ui/.env"
NEXT_PUBLIC_APP_NAME=$APP_NAME
NEXT_PUBLIC_BASE_PATH=$BASE_PATH
NEXT_PUBLIC_ASSET_PREFIX=$ASSET_PREFIX
NEXT_PUBLIC_SERVER_ENDPOINT=$SERVER_ENDPOINT
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=$WALLET_CONNECT_PROJECT_ID
EOF
env:
APP_NAME: canonical-bridge
BASE_PATH: /canonical-bridge
ASSET_PREFIX: /canonical-bridge
SERVER_ENDPOINT: ${{ vars.SERVER_ENDPOINT }}
WALLET_CONNECT_PROJECT_ID: ${{ vars.WALLET_CONNECT_PROJECT_ID }}

- name: Install & build
shell: bash
run: |
node common/scripts/install-run-rush.js install -t @bnb-chain/canonical-bridge-ui
node common/scripts/install-run-rush.js build -t @bnb-chain/canonical-bridge-ui
- name: Pushes to another repository
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source-directory: './apps/canonical-bridge-ui/dist'
destination-github-username: 'wenty22'
destination-repository-name: 'canonical-bridge'
user-email: github-actions[bot]@users.noreply.github.com
target-branch: main

# - name: Deploy docs
# uses: JamesIves/github-pages-deploy-action@v4
# with:
# folder: ./apps/canonical-bridge-ui/dist
# branch: 'gh-pages'
# clean: true
# force: true
8 changes: 1 addition & 7 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: 'setup'
description: Prepare the environment

inputs:
npm-token:
description: 'npm token'
required: false

runs:
using: composite
steps:
Expand Down Expand Up @@ -33,11 +28,10 @@ runs:
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Creating .npmrc
if: inputs.npm-token != ''
shell: bash
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ inputs.npm-token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
12 changes: 0 additions & 12 deletions .github/workflows/alpha-sdk.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/workflows/alpha-widget.yaml

This file was deleted.

100 changes: 0 additions & 100 deletions .github/workflows/gh-pages.yaml

This file was deleted.

55 changes: 25 additions & 30 deletions .github/workflows/alpha.yaml → .github/workflows/qa-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
name: alpha-cicd-trigger-by-comment
name: cicd-trigger-by-comment

on:
workflow_call:
inputs:
package-name:
description: 'package name'
type: string
required: true
default: ''
issue_comment:
types: [created]

jobs:
pre-check:
runs-on: ubuntu-latest
if: github.repository == 'bnb-chain/canonical-bridge' && contains(github.event.comment.body, '/qa-deploy:${{inputs.package-name}}')
if: github.repository == 'bnb-chain/canonical-bridge' && contains(github.event.comment.body, '/qa-deploy')
outputs:
codeowners: ${{ steps.codeowners.outputs.content }}
steps:
Expand Down Expand Up @@ -54,35 +49,35 @@ jobs:
BRANCH_NAME=${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_OUTPUT
- name: get comment
id: get-comment
run: |
#!/bin/bash
input_comment="${{ github.event.comment.body }}"
comment_format=${input_comment// /}
APP_NAME=${comment_format#*:}
echo "APP_NAME=${APP_NAME}" >> $GITHUB_OUTPUT
- name: Checkout code repository
uses: actions/checkout@v4
with:
ref: ${{ steps.pr-env.outputs.BRANCH_NAME }}
token: ${{ secrets.GITHUB_TOKEN }}

- uses: ./.github/actions/setup
with:
npm-token: ${{ secrets.NPM_TOKEN }}

- name: Install & build
shell: bash
run: |
node .release/scripts/install.js
node common/scripts/install-run-rush.js install -t @bnb-chain/${{inputs.package-name}}
node common/scripts/install-run-rush.js build -t @bnb-chain/${{inputs.package-name}}
- name: Deploy github pages
if: contains(steps.get-comment.outputs.APP_NAME, 'canonical-bridge-ui')
uses: ./.github/actions/gh-pages

- name: Enter pre mode
run: pnpm ci:enter
- name: Deploy SDK
if: contains(steps.get-comment.outputs.APP_NAME, 'canonical-bridge-sdk')
uses: ./.github/actions/alpha
with:
app-name: ${{steps.get-comment.outputs.APP_NAME}}

- name: Create and publish versions
uses: changesets/action@v1
- name: Deploy Widget
if: contains(steps.get-comment.outputs.APP_NAME, 'canonical-bridge-widget')
uses: ./.github/actions/alpha
with:
version: pnpm ci:alpha-version
publish: pnpm ci:publish
commit: 'chore: Update versions'
title: 'chore: Update versions'
cwd: '.release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
app-name: ${{steps.get-comment.outputs.APP_NAME}}
8 changes: 2 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
pre-check:
runs-on: ubuntu-latest
if: github.repository == 'bnb-chain/canonical-bridge' && contains(github.event.comment.body, '/qa-deploy:${{inputs.package-name}}')
if: github.repository == 'bnb-chain/canonical-bridge'
outputs:
codeowners: ${{ steps.codeowners.outputs.content }}
steps:
Expand All @@ -28,18 +28,14 @@ jobs:

cicd:
needs: [pre-check]
if: contains(needs.pre-check.outputs.codeowners, github.event.comment.user.login)
if: contains(needs.pre-check.outputs.codeowners, github.event.pull_request.user.login)
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout code repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup
with:
npm-token: ${{ secrets.NPM_TOKEN }}

- name: Install & build
shell: bash
Expand Down

0 comments on commit c0ca75f

Please sign in to comment.