From d1002c282c2ef5204f1808ee204bb0b41c22a0c4 Mon Sep 17 00:00:00 2001 From: syed salman <72004356+syedsalman3753@users.noreply.github.com> Date: Mon, 30 Oct 2023 13:54:17 +0530 Subject: [PATCH] [MOSIP-29251] Updated workflows as per reusable workflow format (#77) * [MOSIP-29251] Updated workflows as per reusable workflow format [MOSIP-25631] Signed-off-by: syed salman * [MOSIP-29251] updated push-trigger.yml [MOSIP-25631] Signed-off-by: syed salman --------- Signed-off-by: syed salman --- .github/workflows/push-trigger.yml | 156 ++++++++++++++++++ .github/workflows/push_trigger.yml | 123 -------------- .github/workflows/storybook_trigger.yml | 28 ---- .github/workflows/tag.yml | 35 ++++ .gitignore | 3 +- .../package.json | 1 + 6 files changed, 194 insertions(+), 152 deletions(-) create mode 100644 .github/workflows/push-trigger.yml delete mode 100644 .github/workflows/push_trigger.yml delete mode 100644 .github/workflows/storybook_trigger.yml create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/push-trigger.yml b/.github/workflows/push-trigger.yml new file mode 100644 index 0000000..ab9a01e --- /dev/null +++ b/.github/workflows/push-trigger.yml @@ -0,0 +1,156 @@ +name: Build and Push + +on: + workflow_dispatch: + inputs: + source_directory: + description: 'Provide mosip plugin utility' + required: true + default: 'sign-in-with-esignet or secure-biometric-interface-integrator or storybook-example' + type: string + destination_branch: + description: 'Provide artifactory branch' + required: true + type: string + push: + branches: + - develop + - master + - 0.* + - 1.* + - MOSIP* + - release* + pull_request: + types: [ opened, synchronize, reopened ] + +jobs: + build-sign-in-with-esignet: + if: "${{ contains(github.event.inputs.source_directory, 'sign-in-with-esignet') || github.event_name == 'pull_request' || github.event_name == 'push' || false }}" + uses: mosip/kattu/.github/workflows/npm-build.yml@master + with: + SERVICE_LOCATION: ./sign-in-with-esignet + BUILD_ARTIFACT: dist + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + sign-in-with-esignet: + runs-on: ubuntu-latest + needs: build-sign-in-with-esignet + env: + SERVICE_LOCATION: ./sign-in-with-esignet + DIST_BUILD_ARTIFACT: dist + BUILD_ARTIFACT: sign-in-with-esignet + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - uses: actions/download-artifact@v3 + with: + name: ${{ env.DIST_BUILD_ARTIFACT }} + path: ${{ env.SERVICE_LOCATION }} + + - name: Zip dist directory + run: | + cd ${{ env.SERVICE_LOCATION }} + unzip ${{ env.DIST_BUILD_ARTIFACT }} + mv dist sign-in-with-esignet + zip -r sign-in-with-esignet.zip sign-in-with-esignet/ + + - name: Upload ZIP artifact + uses: actions/upload-artifact@v3 + with: + name: sign-in-with-esignet + path: sign-in-with-esignet/sign-in-with-esignet.zip + + - name: Copy ZIP file to mosip-plugins directory + run: | + mkdir -p mosip-plugins + cp ./sign-in-with-esignet/sign-in-with-esignet.zip mosip-plugins/ + + - name: Pushes mosip-plugin folder + uses: datalbry/copy_folder_to_another_repo_action@1.0.1 + env: + API_TOKEN_GITHUB: ${{ secrets.ACTION_PAT }} + with: + source_folder: mosip-plugins + destination_repo: mosip/artifactory-ref-impl + destination_folder: artifacts/src/mosip-plugins/sign-in-with-esignet/ + destination_branch: ${{ github.event.inputs.destination_branch }} + user_name: mosip + if: "${{ github.event_name != 'pull_request' }}" + + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,author,commit,workflow,job # selectable (default: repo,message) + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required + if: failure() # Pick up events even if the job fails or is canceled. + + build-secure-biometric-interface-integrator: + if: "${{ contains(github.event.inputs.source_directory, 'secure-biometric-interface-integrator') || github.event_name == 'pull_request' || github.event_name == 'push' || false }}" + uses: mosip/kattu/.github/workflows/npm-build.yml@master + with: + SERVICE_LOCATION: ./secure-biometric-interface-integrator + BUILD_ARTIFACT: dist-sbi-integrator + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + + secure-biometric-interface-integrator: + if: "${{ github.event_name != 'pull_request' }}" + needs: build-secure-biometric-interface-integrator + uses: mosip/kattu/.github/workflows/npm-publish-to-npm-registry.yml@master + with: + SERVICE_LOCATION: ./secure-biometric-interface-integrator + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + + storybook-example: + if: "${{ contains(github.event.inputs.source_directory, 'storybook-example') || github.event_name == 'pull_request' || github.event_name == 'push' || false }}" + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: npm Install and Build storybook-example + run: | + cd storybook-example + npm install + npm run build:version:production + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.ACTION_PAT }} + publish_dir: storybook-example/storybook-static + if: "${{ github.event_name != 'pull_request' }}" + + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,author,commit,workflow,job # selectable (default: repo,message) + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required + if: failure() # Pick up events even if the job fails or is canceled. + + sonarcloud: + if: "${{ github.event_name != 'pull_request' }}" + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - uses: 8398a7/action-slack@v3 + with: + status: ${{ job.status }} + fields: repo,message,author,commit,workflow,job # selectable (default: repo,message) + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required + if: failure() # Pick up events even if the job fails or is canceled. diff --git a/.github/workflows/push_trigger.yml b/.github/workflows/push_trigger.yml deleted file mode 100644 index f8a2a53..0000000 --- a/.github/workflows/push_trigger.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: Build and Push - -on: - workflow_dispatch: - inputs: - source_directory: - description: 'Provide mosip plugin utility' - required: true - default: 'sign-in-with-esignet or secure-biometric-interface-integrator or storybook-example' - type: string - destination_branch: - description: 'Provide artifactory branch' - required: true - type: string - push: - branches: - - develop - - master - - 0.* - pull_request: - types: [ opened, synchronize, reopened ] -jobs: - sign-in-with-esignet: - if: "contains(github.event.inputs.source_directory, 'sign-in-with-esignet')" - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: npm Install - run: | - cd sign-in-with-esignet - npm i - - name: Build APK - run: | - cd sign-in-with-esignet - npm run build - - name: Zip dist directory - run: | - cd sign-in-with-esignet - mv dist sign-in-with-esignet - zip -r sign-in-with-esignet.zip sign-in-with-esignet/ - - - name: Upload ZIP artifact - uses: actions/upload-artifact@v2 - with: - name: sign-in-with-esignet - path: sign-in-with-esignet/sign-in-with-esignet.zip - - - name: Copy ZIP file to mosip-plugins directory - run: | - mkdir -p mosip-plugins - cp ./sign-in-with-esignet/sign-in-with-esignet.zip mosip-plugins/ - - - name: Pushes mosip-plugin folder - uses: datalbry/copy_folder_to_another_repo_action@1.0.1 - env: - API_TOKEN_GITHUB: ${{ secrets.ACTION_PAT }} - with: - source_folder: mosip-plugins - destination_repo: mosip/artifactory-ref-impl - destination_folder: artifacts/src/mosip-plugins/sign-in-with-esignet/ - destination_branch: ${{ github.event.inputs.destination_branch }} - user_name: mosip - - secure-biometric-interface-integrator: - if: "contains(github.event.inputs.source_directory, 'secure-biometric-interface-integrator')" - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: npm Install - run: | - cd secure-biometric-interface-integrator - npm i - - name: Build APK - run: | - cd secure-biometric-interface-integrator - npm run build - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - package_path: './secure-biometric-interface-integrator' - registry-url: 'https://registry.npmjs.org/' - - name: Publish package - run: cd secure-biometric-interface-integrator && npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - - - - storybook-example: - if: "contains(github.event.inputs.source_directory, 'storybook-example')" - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: npm Install and Build storybook-example - run: | - cd storybook-example - npm install - npm run build:version:production - - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.ACTION_PAT }} - publish_dir: storybook-example/storybook-static - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/storybook_trigger.yml b/.github/workflows/storybook_trigger.yml deleted file mode 100644 index 9239469..0000000 --- a/.github/workflows/storybook_trigger.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build and Publish - -on: - push: - branches: - - develop - pull_request: - branches: - - develop -jobs: - build-and-publish: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - - name: npm Install and Build storybook-example - run: | - cd storybook-example - npm install - npm run build:version:production - - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.ACTION_PAT }} - publish_dir: storybook-example/storybook-static diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..9a5b079 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,35 @@ +name: Tagging of repos + +on: + workflow_dispatch: + inputs: + TAG: + description: 'Tag to be published' + required: true + type: string + BODY: + description: 'Release body message' + required: true + default: 'Changes in this Release' + type: string + PRE_RELEASE: + description: 'Pre-release? True/False' + required: true + default: False + type: string + DRAFT: + description: 'Draft? True/False' + required: false + default: False + type: string + +jobs: + tag-branch: + uses: mosip/kattu/.github/workflows/tag.yml@master + with: + TAG: ${{ inputs.TAG }} + BODY: ${{ inputs.BODY }} + PRE_RELEASE: ${{ inputs.PRE_RELEASE }} + DRAFT: ${{ inputs.DRAFT }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 9aa462e..93306ab 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,5 @@ yarn-debug.log* yarn-error.log* .VSCodeCounter */storybook-static -storybook-example/types \ No newline at end of file +storybook-example/types +.idea \ No newline at end of file diff --git a/secure-biometric-interface-integrator/package.json b/secure-biometric-interface-integrator/package.json index 2c5acb8..b7e92ff 100644 --- a/secure-biometric-interface-integrator/package.json +++ b/secure-biometric-interface-integrator/package.json @@ -19,6 +19,7 @@ "secure-biometric-interface-integrator" ], "scripts": { + "verify": "npm run build", "start": "rollup -c -w", "build": "rollup -c", "package": "rollup -c && npm pack",