Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update | GitHub Actions #291

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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'
104 changes: 104 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
104 changes: 20 additions & 84 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,20 +26,17 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: npm install, lint
run: |
npm ci
npm i
npm run lint
- name: npm test
run: |
npm run test
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
Expand All @@ -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/[email protected]
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}}
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint && npm test
9 changes: 8 additions & 1 deletion components/FormFieldRadio/FormFieldRadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ const FormFieldRadioGroup: FunctionComponent<ComponentProps> = ({ label, name, v

return (
<div className="form-radio-group cp-form-radio-group-share" onClick={onClick}>
<input className="form-radio" type="radio" name={name} defaultValue={value} checked={checked} />
<input
className="form-radio"
type="radio"
name={name}
defaultValue={value}
checked={checked}
onChange={onClick}
/>
<label className="form-label" htmlFor={name}>
{label}
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`FormFieldRadioGroup renders correctly 1`] = `
className="form-radio"
defaultValue="this-that"
name="that"
onChange={[Function]}
type="radio"
/>
<label
Expand Down
Loading