feat: add WebdriverIO BDD with Allure report and video recording #124
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release | ||
| on: | ||
| push: | ||
| branches: | ||
| - '**' | ||
| env: | ||
| project-directory: ./ | ||
| repository: 'Greenstand/treetracker-admin-client' | ||
| node-version: '18' | ||
| jobs: | ||
| prepare: | ||
| name: checking and prepare settings for jobs | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| CHANNEL: ${{ steps.resolver.outputs.CHANNEL }} | ||
| S3_BUCKET_SECRET_NAME: ${{ steps.resolver.outputs.S3_BUCKET_SECRET_NAME }} | ||
| CDN_ID_SECRET_NAME: ${{ steps.resolver.outputs.CDN_ID_SECRET_NAME }} | ||
| NO_NEED_TO_BUILD: ${{ steps.resolver.outputs.NO_NEED_TO_BUILD }} | ||
| steps: | ||
| - uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: '18.x' | ||
| - uses: actions/checkout@v4 | ||
| - run: | | ||
| echo "::debug:: begin preparing..."; | ||
| echo "::debug:: branch to rlease: $GITHUB_REF_NAME" | ||
| node <<EOF >> $GITHUB_OUTPUT | ||
| const s3BucketSecretNames = { | ||
| "master-dev": "DEV_CDN_S3_BUCKET", | ||
| "master-prod": "PROD_CDN_S3_BUCKET", | ||
| "freetown-dev": "DEV_CDN_S3_BUCKET_FREETOWN", | ||
| "freetown-prod": "PROD_CDN_S3_BUCKET_FREETOWN", | ||
| "beta-dev": "DEV_STAGING_CDN_S3_BUCKET", | ||
| "beta-prod": "STAGING_CDN_S3_BUCKET", | ||
| "alpha-dev": "DEV_ALPHA_CDN_S3_BUCKET", | ||
| "alpha-prod": "PROD_ALPHA_CDN_S3_BUCKET", | ||
| } | ||
| const cdnIdSecretNames = { | ||
| "master-dev": "DEV_CDN_DISTRIBUTION_ID", | ||
| "master-prod": "PROD_CDN_DISTRIBUTION_ID", | ||
| "freetown-dev": "DEV_CDN_DISTRIBUTION_ID_FREETOWN", | ||
| "freetown-prod": "PROD_CDN_DISTRIBUTION_ID_FREETOWN", | ||
| "beta-dev": "DEV_STAGING_CDN_DISTRIBUTION_ID", | ||
| "beta-prod": "STAGING_CDN_DISTRIBUTION_ID", | ||
| "alpha-dev": "DEV_ALPHA_CDN_DISTRIBUTION_ID", | ||
| "alpha-prod": "PROD_ALPHA_CDN_DISTRIBUTION_ID", | ||
| } | ||
| const releaseJson = require("./.releaserc.json"); | ||
| // Try to get version from env if available | ||
| const version = process.env.VERSION_TO_DEPLOY || ''; | ||
| const ref = process.env.GITHUB_REF_NAME || ''; | ||
| // default env to dev when not explicit | ||
| let env = process.env.ENV_TO_DEPLOY || 'dev'; | ||
| let channel = false; | ||
| if (version) { | ||
| const m = version.match(/^v\d+\.\d+\.\d+(-([\w-\/\.]+)\.\d+)?$/); | ||
| if (!m) { | ||
| throw '::error:: wrong version:' + version; | ||
| } else { | ||
| if(!m[1]) { | ||
| channel = "master"; | ||
| } else { | ||
| const releaseName = m[2]; | ||
| channel = releaseJson.branches.reduce((a,c) => a || (c.prerelease === releaseName && c.channel) || (c.name === releaseName && c.channel), false); | ||
| } | ||
| } | ||
| } | ||
| if(!channel) { | ||
| const branches = releaseJson.branches.map(e => e.name ? e.name : e); | ||
| if (branches.indexOf(ref) === -1) { | ||
| console.log("NO_NEED_TO_BUILD=true"); | ||
| process.exit(0); | ||
| } | ||
| channel = releaseJson.branches.reduce((a,c) => a || (c === ref && c) || (c.name === ref && c.channel), false); | ||
| } | ||
| const key = channel + '-' + env; | ||
| const s3BucketSecretName = s3BucketSecretNames[key]; | ||
| if(!s3BucketSecretName) { | ||
| throw '::error:: can not find s3 bucket secret name by, channel:' + channel + ' env:' + env; | ||
| } | ||
| const cdnIdSecretName = cdnIdSecretNames[key]; | ||
| if(!cdnIdSecretName) { | ||
| throw '::error:: can not find cdn id secret name by, channel:' + channel + ' env:' + env; | ||
| } | ||
| console.log("CHANNEL=" + channel); | ||
| console.log("S3_BUCKET_SECRET_NAME=" + s3BucketSecretName); | ||
| console.log("CDN_ID_SECRET_NAME=" + cdnIdSecretName); | ||
| EOF | ||
| id: resolver | ||
| env: | ||
| VERSION_TO_DEPLOY: ${{ github.event.inputs.version || '' }} | ||
| ENV_TO_DEPLOY: ${{ github.event.inputs.env || '' }} | ||
| - run: | | ||
| echo "channel: ${{ steps.resolver.outputs.CHANNEL}}" | ||
| echo "s3: ${{ steps.resolver.outputs.S3_BUCKET_SECRET_NAME}}" | ||
| echo "cdn: ${{ steps.resolver.outputs.CDN_ID_SECRET_NAME}}" | ||
| echo "need to deplay: ${{ steps.resolver.outputs.NO_NEED_TO_BUILD}}" | ||
| name: Print resolver | ||
| client: | ||
| name: Build Client Project | ||
| runs-on: ubuntu-latest | ||
| needs: prepare | ||
| if: | | ||
| !contains(github.event.head_commit.message, 'skip-ci') && !contains(needs.prepare.outputs.NO_NEED_TO_BUILD, 'true') | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js ${{ env.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ env.node-version }} | ||
| - name: npm clean install | ||
| if: ${{ !env.ACT }} | ||
| run: npm ci --legacy-peer-deps | ||
| working-directory: ${{ env.project-directory }} | ||
| - name: run ESLint | ||
| if: ${{ !env.ACT }} | ||
| run: npm run lint | ||
| working-directory: ${{ env.project-directory }} | ||
| - name: build client dev project | ||
| if: github.event_name == 'push' && github.repository == ${{ env.repository }} | ||
|
Check warning on line 133 in .github/workflows/build_and_release.yaml
|
||
| #if: ${{ !env.ACT }} | ||
| run: npm run build:dev | ||
| working-directory: ${{ env.project-directory }} | ||
| - uses: actions/upload-artifact@v4 | ||
| if: github.event_name == 'push' && github.repository == ${{ env.repository }} | ||
|
Check warning on line 138 in .github/workflows/build_and_release.yaml
|
||
| #if: ${{ !env.ACT }} | ||
| with: | ||
| name: client-bundle | ||
| path: build | ||
| - name: build client project | ||
| if: ${{ !env.ACT }} | ||
| run: npm run build | ||
| working-directory: ${{ env.project-directory }} | ||
| # temporarily disable tests | ||
| # - name: run React tests | ||
| # if: ${{ !env.ACT }} | ||
| # run: npm test | ||
| # working-directory: ${{ env.project-directory }} | ||
| release: | ||
| name: Release semantic version | ||
| needs: [client, prepare] | ||
| runs-on: ubuntu-latest | ||
| if: | | ||
|
Check warning on line 156 in .github/workflows/build_and_release.yaml
|
||
| !contains(github.event.head_commit.message, 'skip-ci') && | ||
| github.event_name == 'push' && | ||
| github.repository == ${{ github.env.repository }} | ||
| permissions: | ||
| contents: write | ||
| issues: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Check out repository code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: true | ||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ env.node-version }} | ||
| - run: npm i -g semantic-release @semantic-release/{git,exec,changelog} | ||
| - name: Run semantic-release | ||
| run: semantic-release | ||
| if: ${{ !env.ACT }} | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| deploy: | ||
| name: Deploy to dev CDN | ||
| runs-on: ubuntu-latest | ||
| needs: [release, prepare] | ||
| if: | | ||
|
Check warning on line 185 in .github/workflows/build_and_release.yaml
|
||
| !contains(github.event.head_commit.message, 'skip-ci') && | ||
| github.event_name == 'push' && | ||
| github.repository == ${{ github.env.repository }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Download bundled client resources | ||
| if: ${{ !env.ACT }} | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: client-bundle | ||
| path: build | ||
| - name: Configure AWS credentials from Test account | ||
| uses: aws-actions/configure-aws-credentials@v1 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_KEY_ID_DADIOR }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_DADIOR }} | ||
| aws-region: us-east-1 | ||
| - name: install-aws-cli | ||
| uses: unfor19/install-aws-cli-action@v1 | ||
| - name: Copy front end resources to s3 bucket | ||
| run: | | ||
| aws s3 sync build s3://${{secrets[needs.prepare.outputs.S3_BUCKET_SECRET_NAME]}} --delete | ||
| - name: Invalidate cloudfront caches | ||
| run: | | ||
| aws cloudfront create-invalidation --distribution-id ${{ secrets[needs.prepare.outputs.CDN_ID_SECRET_NAME]}} --paths "/*" | ||