diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml new file mode 100644 index 00000000..2d492dac --- /dev/null +++ b/.github/workflows/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + # Enable version updates for npm + - package-ecosystem: 'npm' + # Look for `package.json` and `lock` files in the `root` directory + directory: '/' + labels: + - 'npm' + - 'dependencies' + schedule: + interval: 'daily' + + # Enable version updates for GitHub Actions + - package-ecosystem: 'github-actions' + # or GitHub Actions, set the directory to / to check for workflow files in .github/workflows. + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..20ecb8b1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,104 @@ +name: Deploy + +on: + push: + tags: + - v* + branches: + - 'develop' + +jobs: + build: + name: Build + needs: test + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/develop' + steps: + - uses: actions/checkout@v3 + - name: clear old build files + run: | + rm -rf build.zip build + npm ci + + - name: Building + run: | + npm run build + + - name: Bundling + run: | + mkdir build && mv .next build/ && mv public build/ && mv dist/* build/ && mv package.json build/ && mv package-lock.json build/ && mv Dockerfile build/ && mv docker-compose.yml build/ && mv pages/ build/ && mv nginx/ build/ + zip -q -r build.zip build + + - name: Upload build Artifacts + uses: actions/upload-artifact@v3 + with: + name: build + path: ./build.zip + + - name: Upload deploy script as an artifact + uses: actions/upload-artifact@v3 + with: + name: deploy + path: ./deploy_script.sh + + - name: Return to original state + run: | + git reset . + git checkout . + rm -rf build + echo "DONE!" + + deploy: + name: Deploy + needs: build + if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/develop' + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v1 + with: + name: deploy + path: ./deploy_script.sh + + - name: download build artifact + uses: actions/download-artifact@v1 + with: + name: build + path: ./build.zip + + - name: Set env for develop branch or staging + if: contains(steps.get_version.outputs.VERSION, '-beta') || github.ref == 'refs/heads/develop' + run: | + echo "::set-env name=HOST::${{ secrets.DEV_HOST }}" + echo "::set-env name=CMS_URL::${{ secrets.DEV_CMS_URL }}" + + - name: Set env for master branch + if: contains(steps.get_version.outputs.VERSION, '-beta') != true || github.ref != 'refs/heads/develop' + run: | + echo "::set-env name=HOST::${{ secrets.PROD_HOST }}" + echo "::set-env name=CMS_URL::${{ secrets.PROD_CMS_URL }}" + + - name: copy deploy_file via ssh + uses: appleboy/scp-action@master + env: + HOST: ${{ env.HOST }} + USERNAME: ${{ secrets.USERNAME }} + PORT: ${{ secrets.PORT }} + KEY: ${{ secrets.KEY }} + with: + source: './deploy_script.sh,./build.zip' + target: 'deploy_spotlights' + - name: executing remote ssh commands using ssh + uses: appleboy/ssh-action@master + env: + CMS_URL: ${{ env.CMS_URL }} + BITLY_API_KEY: ${{ secrets.BITLY_API_KEY }} + with: + host: ${{ env.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + envs: CMS_URL,BITLY_API_KEY + script: | + export CMS_URL=$CMS_URL + export BITLY_API_KEY=$BITLY_API_KEY + cd ./deploy_spotlights/deploy_script.sh && chmod +x deploy_script.sh && bash deploy_script.sh diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 25a08a94..45fe607b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,13 +1,22 @@ name: Node CI -on: [push, pull_request] +on: + pull_request: + paths-ignore: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet + - '**/README.md' + - '**/dependabot.yml' + - '.github/workflows/nodejs.yml' + - '.github/workflows/deploy.yml' + +concurrency: nodejs jobs: test: + name: Lint & Test runs-on: ubuntu-latest strategy: matrix: - node-version: [12.x] + node-version: [16.x] steps: - uses: actions/checkout@v3 @@ -17,7 +26,7 @@ jobs: node-version: ${{ matrix.node-version }} - name: npm install, lint run: | - npm ci + npm i npm run lint - name: npm test run: | @@ -25,12 +34,9 @@ jobs: env: CI: true build: + name: Build needs: test runs-on: ubuntu-latest - if: contains(' - refs/heads/master - refs/heads/develop - ', github.ref) steps: - uses: actions/checkout@v3 - name: clear old build files @@ -42,83 +48,13 @@ jobs: run: | npm run build - - name: Bundling - run: | - mkdir build && mv .next build/ && mv public build/ && mv dist/* build/ && mv package.json build/ && mv package-lock.json build/ && mv Dockerfile build/ && mv docker-compose.yml build/ && mv pages/ build/ && mv nginx/ build/ - zip -q -r build.zip build - - - name: Upload build Artifacts - uses: actions/upload-artifact@v3 - with: - name: build - path: ./build.zip - - - name: Upload deploy script as an artifact - uses: actions/upload-artifact@v3 - with: - name: deploy - path: ./deploy_script.sh - - - name: Return to original state - run: | - git reset . - git checkout . - rm -rf build - echo "DONE!" - - deploy: - needs: build - if: contains(' - refs/heads/master - refs/heads/develop - ', github.ref) + automerge: + needs: [test, build] runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write steps: - - uses: actions/download-artifact@v1 - with: - name: deploy - path: ./deploy_script.sh - - - name: download build artifact - uses: actions/download-artifact@v1 - with: - name: build - path: ./build.zip - - - name: Set env for develop branch - if: endsWith(github.ref, '/develop') - run: | - echo "::set-env name=HOST::${{ secrets.DEV_HOST }}" - echo "::set-env name=CMS_URL::${{ secrets.DEV_CMS_URL }}" - - - name: Set env for master branch - if: endsWith(github.ref, '/master') - run: | - echo "::set-env name=HOST::${{ secrets.PROD_HOST }}" - echo "::set-env name=CMS_URL::${{ secrets.PROD_CMS_URL }}" - - - name: copy deploy_file via ssh - uses: appleboy/scp-action@master - env: - HOST: ${{ env.HOST }} - USERNAME: ${{ secrets.USERNAME }} - PORT: ${{ secrets.PORT }} - KEY: ${{ secrets.KEY }} - with: - source: './deploy_script.sh,./build.zip' - target: 'deploy_spotlights' - - name: executing remote ssh commands using ssh - uses: appleboy/ssh-action@master - env: - CMS_URL: ${{ env.CMS_URL }} - BITLY_API_KEY: ${{ secrets.BITLY_API_KEY }} + - uses: fastify/github-action-merge-dependabot@v3.2.0 with: - host: ${{ env.HOST }} - username: ${{ secrets.USERNAME }} - key: ${{ secrets.KEY }} - port: ${{ secrets.PORT }} - envs: CMS_URL,BITLY_API_KEY - script: | - export CMS_URL=$CMS_URL - export BITLY_API_KEY=$BITLY_API_KEY - cd ./deploy_spotlights/deploy_script.sh && chmod +x deploy_script.sh && bash deploy_script.sh + github-token: ${{secrets.GITHUB_TOKEN}} diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 00000000..5f9ec673 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run lint && npm test diff --git a/components/FormFieldRadio/FormFieldRadioGroup.tsx b/components/FormFieldRadio/FormFieldRadioGroup.tsx index 7bd641d1..668b0d76 100644 --- a/components/FormFieldRadio/FormFieldRadioGroup.tsx +++ b/components/FormFieldRadio/FormFieldRadioGroup.tsx @@ -17,7 +17,14 @@ const FormFieldRadioGroup: FunctionComponent = ({ label, name, v return (
- + diff --git a/components/FormFieldRadio/__tests__/__snapshots__/FormFieldRadioGroup.spec.tsx.snap b/components/FormFieldRadio/__tests__/__snapshots__/FormFieldRadioGroup.spec.tsx.snap index 05dde309..696f1c33 100644 --- a/components/FormFieldRadio/__tests__/__snapshots__/FormFieldRadioGroup.spec.tsx.snap +++ b/components/FormFieldRadio/__tests__/__snapshots__/FormFieldRadioGroup.spec.tsx.snap @@ -9,6 +9,7 @@ exports[`FormFieldRadioGroup renders correctly 1`] = ` className="form-radio" defaultValue="this-that" name="that" + onChange={[Function]} type="radio" />