diff --git a/.env.example b/.env.example index 5426a3f..595f63e 100644 --- a/.env.example +++ b/.env.example @@ -5,6 +5,3 @@ FIREBASE_PROJECT_ID= FIREBASE_STORAGE_BUCKET= FIREBASE_MESSAGING_SENDER_ID= FIREBASE_APP_ID= -DB_SESSIONS_REF=sessions -DB_USERS_REF=sessions_users -DB_CARDS_REF=sessions_cards diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..86739cb --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,76 @@ +name: CD +on: + create: + tags: + - v* +jobs: + build-and-test: + runs-on: windows-latest + steps: + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - run: npm ci + + - run: npm run build + env: + FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} + FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }} + FIREBASE_DATABASE_URL: ${{ secrets.FIREBASE_DATABASE_URL }} + FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} + FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }} + FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }} + FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} + +# - name: Run tests +# run: npm run test +# +# - name: Run visual regression tests +# run: npm run test:integration +# +# - name: Upload screenshots diffs +# uses: actions/upload-artifact@v2 +# if: always() +# with: +# name: screenshots +# path: src/**/__diff_output__ + + - name: Upload build + uses: actions/upload-artifact@v2 + with: + name: build + path: public + + deploy: + needs: [build-and-test] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - run: ls -la && ls -la ./public + + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + name: build + path: public + + - run: ls -la && ls -la ./public + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + BRANCH: gh-pages + FOLDER: public + CLEAN: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6d009f6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,43 @@ +name: CI +on: + push: + branches-ignore: + - gh-pages +jobs: + build-and-test: + runs-on: windows-latest + steps: + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - run: npm ci + + - run: npm run build + env: + FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} + FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }} + FIREBASE_DATABASE_URL: ${{ secrets.FIREBASE_DATABASE_URL }} + FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} + FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }} + FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }} + FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} + + - name: Run tests + run: npm run test + + - name: Run visual regression tests + run: npm run test:integration + + - name: Upload screenshots diffs + uses: actions/upload-artifact@v2 + if: always() + with: + name: screenshots + path: src/**/__diff_output__ diff --git a/package.json b/package.json index 10de147..4ba49ee 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "jest:integration": "jest --config ./jest/jest.config.integration.js", "test:integration": "start-server-and-test storybook:test http-get://localhost:9009 jest:integration", "test:all": "run-p test test:integration", - "storybook:test": "start-storybook --ci -p 9009", + "storybook:test": "start-storybook --ci -p 9009 --quiet", "storybook": "start-storybook -p 9010", "prettier:staged": "prettier --write", "eslint:staged": "eslint --fix", diff --git a/src/service.js b/src/service.js index 6f9ea6c..cf2c6ba 100644 --- a/src/service.js +++ b/src/service.js @@ -17,9 +17,9 @@ firebase.initializeApp({ }); const database = firebase.database(); -const DB_SESSIONS_REF = process.env.DB_SESSIONS_REF; -const DB_USERS_REF = process.env.DB_USERS_REF; -const DB_CARDS_REF = process.env.DB_CARDS_REF; +const DB_SESSIONS_REF = 'sessions'; +const DB_USERS_REF = 'sessions_users'; +const DB_CARDS_REF = 'sessions_cards'; /** * Инициализация игровой сессии diff --git a/webpack.config.js b/webpack.config.js index f416788..599e7eb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,7 +11,7 @@ const isDev = process.env.NODE_ENV !== 'production'; const isAnalysis = process.env.NODE_ENV === 'analysis'; const plugins = [ - new Dotenv(), + new Dotenv({ systemvars: true }), new HtmlWebpackPlugin({ template: './assets/index.html' }), new MiniCssExtractPlugin({ filename: '[name].[hash].css',