Node.js CI #659
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Node.js CI | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
schedule: | |
- cron: '0 */12 * * *' | |
jobs: | |
deploy-secrets-to-napptive: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
curl --location --request POST 'https://api.github.com/repos/Jeff-Tian/uni-orders-secrets/dispatches' \ | |
--header 'Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}' \ | |
--header 'Accept: application/vnd.github+json' \ | |
--header 'Content-Type: application/json' \ | |
--data-raw '{"event_type": "webhook"}' | |
deploy-napptive: | |
name: Deploy to napptive | |
needs: deploy-secrets-to-napptive | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: napptive-actions/playground-github-action@v4.1.0 | |
env: | |
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }} | |
with: | |
cmd: "apps deploy uni-orders.yaml" | |
update-napptive: | |
name: update napptive | |
if: ${{ always() }} | |
needs: deploy-napptive | |
runs-on: ubuntu-latest | |
env: | |
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }} | |
MY_OPENSSL_PASSWORD: ${{ secrets.MY_OPENSSL_PASSWORD }} | |
steps: | |
- run: echo "${PLAYGROUND_PAT}" | openssl enc -e -aes-256-cbc -a -pbkdf2 -iter 5 -k "${MY_OPENSSL_PASSWORD}" | |
- uses: actions/checkout@v2 | |
- run: echo "Downloading NAPPTIVE Playground CLI" | |
- run: curl -O https://storage.googleapis.com/artifacts.playground.napptive.dev/installer.sh && bash installer.sh | |
- run: echo "Downloading Kubectl" | |
- run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" | |
- run: chmod +x kubectl | |
- run: echo "Login into NAPPTIVE Playground" | |
- run: playground login --pat | |
- run: playground get-kubeconfig | |
- run: ls ~/.napptive/default/napptive-kubeconfig | |
- name: update | |
env: | |
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }} | |
run: | | |
export PATH=$PATH:$(pwd) | |
echo "Forcing rolling update to download newest image" | |
export IMAGE="jefftian/uni-orders:latest" | |
echo "Update image... ${IMAGE}" | |
export PATCH='{"spec":{"workload":{"spec":{"containers":\ [{"name":"uni-orders", "image":"${IMAGE}"}]}}}}' | |
echo "patch = ${PATCH}" | |
kubectl --kubeconfig ~/.napptive/default/napptive-kubeconfig patch deploy uni-orders --patch '{"spec":{"template":{"spec":{"containers":[{"image":"jefftian/uni-orders","name":"uni-orders"}]}}}}' --type=merge | |
deploy-okteto: | |
if: ${{false}} # disable okteto deployment as my okteto env was deleted | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
- run: curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl | |
- run: chmod +x ./kubectl | |
- run: sudo mv ./kubectl /usr/local/bin/kubectl | |
- run: mkdir ${HOME}/.kube | |
- run: npm i -g k8ss | |
- run: echo -e "machine github.com\n login ${{secrets.GH_TOKEN}}" > ~/.netrc | |
- run: git clone https://github.com/Jeff-Tian/k8s-config.git ${HOME}/k8s-config | |
- run: npm run okteto | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'npm' | |
- run: yarn | |
- run: echo "${{secrets.DOCKER_PASSWORD}}" | docker login -u "${{secrets.DOCKER_USERNAME}}" --password-stdin | |
- run: sh .travis/ci.sh | |
test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: nopwd | |
POSTGRES_USER: postgres | |
POSTGRES_DB: orders | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
matrix: | |
node-version: [14.x, 16.x, 18.x] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- run: yarn | |
- run: yarn build | |
- run: yarn test | |
- run: yarn test:e2e | |
- run: yarn test:cov |