Skip to content

Merge pull request #84 from maslick/maslick-patch-1 #43

Merge pull request #84 from maslick/maslick-patch-1

Merge pull request #84 from maslick/maslick-patch-1 #43

Workflow file for this run

name: prod
on:
push:
branches: [master]
jobs:
wasm:
name: Build WASM (react)
runs-on: ubuntu-latest
steps:
- name: checkout source code
uses: actions/checkout@master
- name: pull emscripten-zbar-sdk
run: docker pull maslick/emscripten-zbar-sdk
- name: build wasm
run: docker run -e INPUT_FILE=zbar/qr.cpp -e OUTPUT_FILE=zbar -e OUTPUT_DIR=public/wasm -v $(pwd):/app maslick/emscripten-zbar-sdk make
- name: upload wasm artifact
uses: actions/upload-artifact@v1
with:
name: wasms
path: public/wasm
- name: job failed
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Oops! Build failed (wasm job) :(
See https://github.com/maslick/koder-react/actions for more details
build:
name: Build React app
runs-on: ubuntu-latest
needs: wasm
steps:
- name: checkout source code
uses: actions/checkout@v2
- name: install node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache yarn modules
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: download wasm artifact
uses: actions/download-artifact@v1
with:
name: wasms
- name: copy artifacts
run: cp -r wasms/* public/wasm/
- name: install npm dependencies
run: yarn install --frozen-lockfile
- name: build React bundle
run: GENERATE_SOURCEMAP=false npm run build
- name: upload js bundle artifact
uses: actions/upload-artifact@v1
with:
name: bundle
path: build
- name: job failed
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Oops! Build failed (build job) :(
See https://github.com/maslick/koder-react/actions for more details
npm:
name: Publish to NPM
runs-on: ubuntu-latest
needs: wasm
steps:
- name: checkout source code
uses: actions/checkout@v2
- name: install node
uses: actions/setup-node@v2
with:
node-version: '14'
- name: download wasm artifact
uses: actions/download-artifact@v1
with:
name: wasms
- name: copy artifacts
run: cp -r wasms/* public/wasm/
- name: Prepare tarball
run: npm run pre-publish-node
- name: Publish to NPM
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: cd dist && npm publish --access public || true
- name: upload NPM artifact
uses: actions/upload-artifact@v1
with:
name: npm
path: dist
- name: job failed
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Oops! Build failed (build job) :(
See https://github.com/maslick/koder-react/actions for more details
deploy:
name: Deploy to prod
runs-on: ubuntu-latest
needs: build
environment:
name: koder.prod
url: https://koder-prod.web.app
steps:
- name: checkout source code
uses: actions/checkout@master
- name: download js bundle artifact
uses: actions/download-artifact@v1
with:
name: bundle
- name: copy artifacts
run: mv bundle build
- name: push to Firebase
uses: w9jds/[email protected]
with:
args: deploy --only hosting:koder-prod
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
- name: send Telegram success message
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Success!
A ${{ github.event_name }} event triggered the pipeline.
Ref: ${{ github.ref }}
Commit hash: ${{ github.sha }}
See https://github.com/maslick/koder-react/actions for more details
- name: job failed
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Oops! Build failed (deploy job) :(
See https://github.com/maslick/koder-react/actions for more details