Skip to content

Beta release - 59

Beta release - 59 #59

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: true
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 }}
jobs:
merge-dev-into-main:
name: Merge Dev into Main
runs-on: ubuntu-latest
timeout-minutes: 10
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Git config
run: |
git config --local user.email "[email protected]"
git config --local user.name "Badman Releaser"
- name: Merge develop in to main
run: |
# Merge develop into main
git merge --no-ff origin/develop -m "Merging develop into main"
git push origin main
main:
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
needs: [merge-dev-into-main]
outputs:
NEW_VERSION: ${{ steps.create_release.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: set SHAs
run: |
# run code only on main branch
if [ ${{ github.ref == 'refs/heads/main' }} ]; then
# get last major tag (not including beta)
TAG_VERSION=$(git describe --match 'v*' --exclude='*beta*' --abbrev=0 --tags $(git rev-list --tags --max-count=1))
else
# get last tag
TAG_VERSION=$(git describe --match 'v*' --abbrev=0 --tags $(git rev-list --tags --max-count=1))
fi
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
- uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node
- run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml"
- run: npm install
- run: npx nx affected -t lint test build
- name: Run Playwright tests
run: npx nx run-many -t e2e
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
npx playwright merge-reports --reporter=html,github ./blob-reports
## for copy pasting in shell
# npx playwright show-report
- 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 }}
# deploy the new packages
- name: Deploy
run: npx nx affected -t deploy --no-agents
env:
API_HOOK: ${{ github.ref == 'refs/heads/main' && secrets.PROD_API_HOOK || secrets.BETA_API_HOOK }}
WORKER_SYNC_HOOK: ${{ github.ref == 'refs/heads/main' && secrets.PROD_WORKER_SYNC_HOOK || secrets.BETA_WORKER_SYNC_HOOK }}
WORKER_RANKING_HOOK: ${{ github.ref == 'refs/heads/main' && secrets.PROD_WORKER_RANKING_HOOK || secrets.BETA_WORKER_RANKING_HOOK }}
- 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
merge-main-into-dev:
name: Merge Main into Dev
runs-on: ubuntu-latest
needs: [main]
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.ref == 'refs/heads/main'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set Git config
run: |
git config --local user.email "[email protected]"
git config --local user.name "Badman Releaser"
- name: Merge main back to develop
run: |
git fetch --unshallow
git checkout develop
git pull
git merge --no-ff origin/main -m "chore(merge): v${{ needs.main.outputs.NEW_VERSION }} to develop"
git push origin develop