Skip to content

Beta release - 325 #325

Beta release - 325

Beta release - 325 #325

Workflow file for this run

name: Release Workflow v2
on:
# manual trigger
workflow_dispatch:
inputs:
# main branch name
e2e-tests:
description: 'Do e2e tests'
required: true
default: false
type: boolean
# Needed for nx-set-shas when run on the main branch
permissions:
actions: read
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
run-name: ${{ github.ref == 'refs/heads/main' && 'Prod' || 'Beta' }} release ${{ inputs.e2e-tests && 'with E2E tests' || '' }} - ${{ github.run_number }}
# variable to use certain package manager
env:
PACKAGE_MANAGER: npm # Change this to 'bun', 'yarn', or 'pnpm' as needed.
jobs:
main:
runs-on: ubuntu-latest
outputs:
NEW_VERSION: ${{ steps.create_release.outputs.new_version }}
steps:
- uses: actions/checkout@v4
- name: Merge development -> main
uses: devmasx/merge-branch@master
if: github.ref == 'refs/heads/main'
with:
type: now
from_branch: develop
target_branch: main
message: 'chore(merge): merge develop into main'
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull main
if: github.ref == 'refs/heads/main'
run: git pull origin main
- name: set SHAs
run: |
# run code only on main branch
TAG_VERSION=$(git describe --first-parent --match 'v*' --abbrev=0 --tags)
echo "Found tag: $TAG_VERSION"
LAST_TAG_HASH=$(git rev-list -n 1 $TAG_VERSION)
echo "Found hash: $LAST_TAG_HASH"
# Set NX_BASE to the last tag
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV
# Set NX_HEAD to the current commit
echo "NX_HEAD=origin/${{github.ref_name}}" >> $GITHUB_ENV
- name: Setup package manager
run: |
if [ "${{ env.PACKAGE_MANAGER }}" = "bun" ]; then
echo "Installing Bun..."
curl -fsSL https://bun.sh/install | bash
export PATH="/root/.bun/bin:$PATH"
elif [ "${{ env.PACKAGE_MANAGER }}" = "pnpm" ]; then
echo "Installing pnpm..."
npm install -g pnpm
elif [ "${{ env.PACKAGE_MANAGER }}" = "yarn" ]; then
echo "Installing Yarn..."
npm install -g yarn
fi
- name: Start CI run
run: |
if [ "${{ env.PACKAGE_MANAGER }}" = "bun" ]; then
npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets-bun.yaml"
else
npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml"
fi
- name: Install dependencies
run: |
${{ env.PACKAGE_MANAGER }} install
- name: Run affected commands
run: |
${{ env.PACKAGE_MANAGER }} run nx affected -t test build -c ci
- name: Run Playwright tests
run: |
${{ env.PACKAGE_MANAGER }} run nx affected --parallel 1 -t e2e-ci
id: run-e2e-tests
if: ${{ inputs.e2e-tests }}
- name: e2e reports
# Always run if the e2e-tests input is true
if: ${{ inputs.e2e-tests && (steps.run-e2e-tests.outcome == 'success' || steps.run-e2e-tests.outcome == 'failure') }}
run: |
echo "Combine all the reports into a single report"
# check if the "blob-reports" root directory exists and if it does, remove it and recreate it
if [ -d "blob-reports" ]; then
rm -rf blob-reports
fi
# create the "blob-reports" root directory
mkdir blob-reports
# copy all the reports into the "blob-reports" root directory
cp apps/**/blob-report/*.zip ./blob-reports
# create nx report
bun playwright merge-reports --reporter=html,github ./blob-reports
## for copy pasting in shell
# bun playwright show-report
- name: coverage reports
run: npx --yes lcov-result-merger 'coverage/**/lcov.info' 'coverage/lcov.info'
- name: Set Git config
run: |
git config --local user.email "[email protected]"
git config --local user.name "Badman Releaser"
# create release on master en develop
- name: Create release
id: create_release
run: node scripts/release.js --dry-run=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: stop agents
run: npx nx-cloud complete-ci-run
if: always()
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- uses: actions/upload-artifact@v3
if: always()
with:
name: coverage-report
path: coverage/lcov.info
retention-days: 30
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Merge main -> develop
uses: devmasx/merge-branch@master
if: github.ref == 'refs/heads/main'
with:
type: now
from_branch: main
target_branch: develop
message: 'chore(merge): merge main into develop'
github_token: ${{ secrets.GITHUB_TOKEN }}
# deploy the new packages
- name: Deploy to Prod
if: github.ref == 'refs/heads/main'
run: ${{ env.PACKAGE_MANAGER }} run nx affected -t deploy --no-agents
env:
API_HOOK: ${{ secrets.PROD_API_HOOK }}
WORKER_SYNC_HOOK: ${{ secrets.PROD_WORKER_SYNC_HOOK }}
WORKER_RANKING_HOOK: ${{ secrets.PROD_WORKER_RANKING_HOOK }}
- name: Deploy to Beta
run: ${{ env.PACKAGE_MANAGER }} run nx affected -t deploy --no-agents
env:
API_HOOK: ${{ secrets.BETA_API_HOOK }}
WORKER_SYNC_HOOK: ${{ secrets.BETA_WORKER_SYNC_HOOK }}
WORKER_RANKING_HOOK: ${{ secrets.BETA_WORKER_RANKING_HOOK }}