From 01607133aa5440db4aaba47341962b43d1b98064 Mon Sep 17 00:00:00 2001 From: Brice Redmond Date: Tue, 5 Nov 2024 14:20:53 -0800 Subject: [PATCH] [patch] fix gha for pushing to stage --- .github/workflows/build-push.yml | 74 +++++++++++++++++++++++++ .github/workflows/deploy-qa.yml | 93 ------------------------------- .github/workflows/gate-keep.yml | 94 -------------------------------- .github/workflows/test.yml | 54 ------------------ deployment/deploy-qa.sh | 3 +- dev.config | 4 +- 6 files changed, 78 insertions(+), 244 deletions(-) create mode 100644 .github/workflows/build-push.yml delete mode 100644 .github/workflows/deploy-qa.yml delete mode 100644 .github/workflows/gate-keep.yml delete mode 100644 .github/workflows/test.yml mode change 100644 => 100755 deployment/deploy-qa.sh diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 00000000..4deb81ce --- /dev/null +++ b/.github/workflows/build-push.yml @@ -0,0 +1,74 @@ +name: Deploy Staging +on: push + +env: + NODE_VERSION: 18 + JAVA_VERSION: 11 + JAVA_DISTRIBUTION: 'adopt' + +jobs: + build-push: + name: run tests, build and push + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Node ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + + - name: Install dependencies + run: npm run ci + + - name: Lint tests + run: npm run lint + + - name: Run tests + run: npm run test-report + + - name: Test Report + uses: dorny/test-reporter@v1 + if: always() + with: + name: Unit Tests + fail-on-error: true, + path: test-results.json # Path to test results + reporter: mocha-json # Format of test results + + - name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + id: test-results + if: always() + with: + files: "test-results.json" + + - name: Run coverage + run: npm run cover + + - name: upload codecov + uses: codecov/codecov-action@v4 + + - name: Check whether we will be able to make the release + run: bash ${GITHUB_WORKSPACE}/deployment/build-test.sh + + - name: AWS, credentials setup +# if: ${{ github.ref == 'refs/heads/master' }} + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-west-1 + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Deploy updated builds to staging +# if: ${{ github.ref == 'refs/heads/master' }} + id: build + run: | + ./deployment/deploy-qa.sh \ No newline at end of file diff --git a/.github/workflows/deploy-qa.yml b/.github/workflows/deploy-qa.yml deleted file mode 100644 index 063e7cf5..00000000 --- a/.github/workflows/deploy-qa.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Deploy QA -on: - pull_request: - types: [closed] - branches: - - main - paths-ignore: - - docs/** - - README.md -env: - BRANCH_NAME: '${{ github.event.inputs.branch_name || github.head_ref || github.ref_name }}' - NODE_VERSION: 18 - JAVA_VERSION: 11 - JAVA_DISTRIBUTION: 'adopt' - -jobs: - test-unit: - name: Unit tests - runs-on: [ ubuntu-latest ] - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Install dependencies - run: npm run ci - - - name: Run tests - id: runTests - run: npm run test - - - name: Run coverage - id: runCover - if: steps.runTests.outcome == 'success' - run: npm run cover - - - name : upload codecov - uses: codecov/codecov-action@v4 - if: steps.runCover.outcome == 'success' - - test-lint: - name: Lint - runs-on: [ ubuntu-latest ] - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Install dependencies - run: npm run ci - - - name: Lint tests - run: npm run lint - - deploy-qa: - name: Deploy-QA - needs: [test-unit,test-lint] - if: ${{ github.ref_name == 'main' && github.event.pull_request.merged == true }} - runs-on: [ ubuntu-latest ] - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: ${{ env.JAVA_DISTRIBUTION }} - - - name: Install dependencies - run: npm run ci - - - name: Call the Build bash script for QA - id: build - run: bash ${GITHUB_WORKSPACE}/deployment/deploy-qa.sh - - - diff --git a/.github/workflows/gate-keep.yml b/.github/workflows/gate-keep.yml deleted file mode 100644 index 09fab731..00000000 --- a/.github/workflows/gate-keep.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Gate Keeping -on: - push: -env: - NODE_VERSION: 18 - JAVA_VERSION: 11 - JAVA_DISTRIBUTION: 'adopt' - -jobs: - test-unit: - name: Unit tests - runs-on: [ ubuntu-latest ] - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Install dependencies - run: npm run ci - - - name: Run tests - run: npm run test-report - - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() - with: - name: Unit Tests - fail-on-error: true, - path: test-results.json # Path to test results - reporter: mocha-json # Format of test results - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - id: test-results - if: always() - with: - files: "test-results.json" - - - name: Run cover - run: npm run cover - - - name : upload codecov - uses: codecov/codecov-action@v4 - - test-lint: - name: Lint - runs-on: [ ubuntu-latest ] - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - - name: Install dependencies - run: npm run ci - - - name: Lint tests - run: npm run lint - - test-build: - name: Test-build - needs: [test-unit,test-lint] - runs-on: [ ubuntu-latest ] - steps: - - name: Checkout ${{ github.ref_name }} - uses: actions/checkout@v4 - - - name: Install Node ${{ env.NODE_VERSION }} - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - cache: 'npm' - - name: Set up JDK 11 - uses: actions/setup-java@v4 - with: - java-version: ${{ env.JAVA_VERSION }} - distribution: ${{ env.JAVA_DISTRIBUTION }} - - - name: Install dependencies - run: npm run ci - - - name: Call the Build bash script for QA - run: bash ${GITHUB_WORKSPACE}/deployment/build-test.sh - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f11c53bb..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: demo -on: - workflow_dispatch: - inputs: - branch_name: - description: 'Name of the branch' - required: true - default: 'main' - - perform_deploy_qa: - description: 'Want to deploy to QA' - required: true - type: boolean - - perform_deploy_prod: - description: 'Want to deploy to Prod' - required: true - type: boolean - - version: - type: choice - description: Version for Prod release - options: - - major - - minor - - patch - push: - branches: - - main - - releases/** - paths-ignore: - - docs/** - - README.md - pull_request: - types: [opened, reopened, edited, closed] - branches: - - main - - releases/** - paths-ignore: - - docs/** - - README.md - -env: - BRANCH_NAME: '${{ github.event.inputs.branch_name || github.head_ref || github.ref_name }}' -jobs: - build: - runs-on: [small] - steps: - - name: Run tests - run: echo "Branch name is $BRANCH_NAME" - - name: Echo - run: | - echo "Version selected is, ${{ github.event.inputs.version }}!" - echo "- qa ${{ inputs.perform_deploy_qa }}!" diff --git a/deployment/deploy-qa.sh b/deployment/deploy-qa.sh old mode 100644 new mode 100755 index f1131d25..388ad54c --- a/deployment/deploy-qa.sh +++ b/deployment/deploy-qa.sh @@ -24,10 +24,11 @@ NC='\033[0m' echo -en "${GREEN}Pushing to CDN ...${NC}\n" aws s3 cp --content-type="text/javascript" --content-encoding="gzip" dist/build.min.js.gz s3://branch-cdn/branch-staging-latest.min.js --cache-control "max-age=300" - aws s3 cp dist/example.html s3://branch-cdn/example-staging.html + aws s3 cp example.html s3://branch-cdn/example-staging.html echo -en "Invalidating cloudfront distribution for staging ...\n" aws configure set preview.cloudfront true aws cloudfront create-invalidation --distribution-id E10P37NG0GMER --paths /branch-staging-latest.min.js /example-staging + # Exit prompts echo -en "${GREEN}Done deploy QA script ...${NC}\n" diff --git a/dev.config b/dev.config index 7bb591ad..79933e75 100644 --- a/dev.config +++ b/dev.config @@ -1,5 +1,5 @@ { - "APIEndpoint": "https://api2.branch.io", - "sdkKey": null, + "APIEndpoint": "https://api.stage.branch.io", + "sdkKey": "key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv", "port": "3000" } \ No newline at end of file