Skip to content

CI

CI #6

Workflow file for this run

name: CI
on: # Trigger the workflow on push to main, pull request to main, or manual trigger
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
reserve-ci-instance: # Reserve an instance
runs-on: ubuntu-latest
outputs:
mpkit-url: ${{ steps.reserve.outputs.mpkit-url }}
report-path: ${{ steps.reserve.outputs.report-path }}
steps:
- name: Get ci-instance-url
id: reserve
uses: Platform-OS/[email protected] # Use our custom action to reserve an instance
with:
repository-url: https://alex-demo-master.staging.oregon.platform-os.com
method: reserve
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
deploy:
needs: ["reserve-ci-instance"] # Don't run this job until the reserve-ci-instance job is done
runs-on: ubuntu-latest
env:
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }}
POS_CI_REPO_ACCESS_TOKEN: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
UPLOAD_HOST: ${{ secrets.UPLOAD_HOST }}
CI: true
steps:
- name: Checkout your repository
uses: actions/checkout@v4
- name: Build your project
shell: sh
run: |
set -eu
npm install
npm run build
- name: Deploy your project to the reserved instance
shell: sh
run: |
set -eu
./seed.sh
tests:
needs: ["reserve-ci-instance", "deploy"] # Don't run this job until both the reserve-ci-instance and deploy jobs are done
runs-on: ubuntu-latest
env:
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }}
REPORT_PATH: ${{ needs.reserve-ci-instance.outputs.report-path }}
UPLOAD_HOST: ${{ secrets.UPLOAD_HOST }}
CI: true
steps:
- name: Run unit tests
shell: sh
run: |
set -eu
npm run ci:test:unit
- name: Clean up after unit tests and prepare environment for E2E tests
shell: sh
run: |
set -e
./seed.sh
- uses: Platform-OS/[email protected]
name: Run E2E tests
if: success() || failure() # Run E2E tests even if unit tests fail, this will allow you to get feedback on the E2E tests
with:
test-name: e2e-as-defined-in-package-json # This is the name of the script that runs your E2E tests
cleanup:
if: ${{ always() }}
needs: ["reserve-ci-instance", "deploy", "tests"]
runs-on: ubuntu-latest
steps:
- name: release ci-instance-url
uses: Platform-OS/[email protected] # Use our custom action to release the instance
with:
method: release
repository-url: https://ci-repository.staging.oregon.platform-os.com
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
# deploy-qa: # Deploy to QA on push to master and after tests pass
# if: ${{ github.ref_name == 'master' }}
# needs: ["tests"] # Don't run this job until the tests job is done and successful
# runs-on: ubuntu-latest
# env:
# MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }}
# MPKIT_TOKEN: ${{ secrets.MPKIT_TOKEN }}
# MPKIT_URL: ${{ QA-HOST-URL }}
# POS_CI_REPO_ACCESS_TOKEN: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }}
# CI: true
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
#
# - name: Build
# shell: sh
# run: |
# set -eu
# npm ci
# npm run build
#
# - name: Deploy
# shell: sh
# run: |
# set -eu
# pos-cli deploy