CI #47
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
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 | |
container: alpine:3.20 | |
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/ci-repository-reserve-instance-url@mask-token | |
with: | |
repository-url: ${{ vars.CI_REPOSITORY_URL }} | |
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 | |
container: platformos/playwright:5.1.5-1.47.2 | |
env: | |
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }} | |
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }} | |
POS_CI_REPO_ACCESS_TOKEN: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }} | |
CI: true | |
steps: | |
- name: get-mpkit-token | |
id: get-token | |
uses: Platform-OS/ci-repository-reserve-instance-url@mask-token | |
with: | |
method: get-token | |
repository-url: ${{ vars.CI_REPOSITORY_URL }} | |
pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }} | |
- name: use mpkit-token | |
env: | |
TOKEN: "${{ steps.get-token.outputs.mpkit-token }}" | |
run: | | |
echo hide-token | |
echo "${{ env.TOKEN }}" | |
- name: Checkout your repository | |
uses: actions/checkout@v4 | |
- name: Install pos-cli | |
shell: sh | |
run: | | |
set -eu | |
npm install -g @platformos/pos-cli | |
- name: Deploy your project to the reserved instance | |
env: | |
MPKIT_TOKEN: ${{ steps.get-token.outputs.mpkit-token }} | |
shell: sh | |
run: | | |
set -eu | |
mkdir -p /tmp/allow-data-clean/app | |
cp app/config.yml /tmp/allow-data-clean/app | |
cd /tmp/allow-data-clean | |
echo 'allow_data_clean: true' >> app/config.yml | |
pos-cli deploy -p | |
cd - | |
rm -rf /tmp/allow-data-clean | |
export CONFIRMATION_TEXT=$(echo "$MPKIT_URL" | sed 's|https://||') | |
pos-cli data clean --auto-confirm --include-schema | |
pos-cli deploy | |
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 | |
container: platformos/playwright:5.1.5-1.47.2 | |
env: | |
MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }} | |
MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }} | |
REPORT_PATH: ${{ needs.reserve-ci-instance.outputs.report-path }} | |
UPLOAD_HOST: ${{ vars.TEST_REPORTS_UPLOAD_HOST }} | |
CI: true | |
steps: | |
- name: Checkout your repository | |
uses: actions/checkout@v4 | |
- name: Run unit tests | |
shell: sh | |
run: | | |
set -eu | |
npm run test | |
cleanup: | |
if: ${{ always() }} | |
needs: ["reserve-ci-instance", "deploy", "tests"] | |
runs-on: ubuntu-latest | |
container: alpine:3.20 | |
steps: | |
- name: release ci-instance-url | |
uses: Platform-OS/ci-repository-reserve-instance-url@mask-token | |
with: | |
method: release | |
repository-url: ${{ vars.CI_REPOSITORY_URL }} | |
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 |