From 01093e4c4d07e60f06cdc027d37711a7b4a8c9f1 Mon Sep 17 00:00:00 2001 From: Thisyahlen Date: Tue, 26 Mar 2024 09:41:44 +0800 Subject: [PATCH] ci: add actions in github --- .github/actions/build/action.yml | 13 +++++++++++++ .github/actions/npm_install/action.yml | 21 +++++++++++++++++++++ .github/workflows/build-and-deploy-test.yml | 12 ++++++------ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/npm_install/action.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..84fe357 --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,13 @@ +name: Build +description: Build dist +inputs: + target: + description: 'Target Environment' + required: true + default: staging +runs: + using: composite + steps: + - name: Building dist for ${{ inputs.target }} + run: node_modules/grunt/bin/grunt releaseci --${{ inputs.target }} + shell: bash diff --git a/.github/actions/npm_install/action.yml b/.github/actions/npm_install/action.yml new file mode 100644 index 0000000..bce743f --- /dev/null +++ b/.github/actions/npm_install/action.yml @@ -0,0 +1,21 @@ +name: npm_install +description: Install npm packages +runs: + using: composite + steps: + - name: restore_cache + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + with: + key: node-{{ checksum "package-lock.json" }} + path: UPDATE_ME + restore-keys: |- + node-{{ checksum "package-lock.json" }} + node- + - name: Install npm packages + run: npm ci + shell: bash + - name: save_cache + uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 + with: + path: node_modules + key: node-{{ checksum "package-lock.json" }} diff --git a/.github/workflows/build-and-deploy-test.yml b/.github/workflows/build-and-deploy-test.yml index 49f007d..99d8a36 100644 --- a/.github/workflows/build-and-deploy-test.yml +++ b/.github/workflows/build-and-deploy-test.yml @@ -19,11 +19,11 @@ jobs: checks: write pull-requests: write steps: - # - name: Verify user - # uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1" - # with: - # username: ${{github.event.pull_request.user.login}} - # token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + - name: Verify user + uses: "deriv-com/shared-actions/.github/actions/verify_user_in_organization@v1" + with: + username: ${{github.event.pull_request.user.login}} + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - name: Post preview build comment id: post_preview_build_comment @@ -44,7 +44,7 @@ jobs: node-version: 20.x - name: Install dependencies - uses: "./.github/actions/npm_install_from_cache" + uses: "./.github/actions/npm_install" - name: Build uses: "./.github/actions/build"