Update target env #10
This file contains hidden or 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: Deploy Production | |
env: | |
APP_LOCATION: "" | |
OUTPUT_LOCATION: "packages/website/build" | |
on: | |
push: | |
branches: ["release/*"] | |
permissions: | |
contents: read | |
jobs: | |
deploy-production: | |
runs-on: ubuntu-latest | |
name: Deploy to Production | |
environment: Production | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
registry-url: "https://registry.npmjs.org" | |
- name: Enable Corepack | |
run: npm i -g corepack@latest | |
- name: Install pnpm | |
run: corepack prepare | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Build UI Package | |
run: pnpm ui build | |
- name: Build Documentation | |
run: pnpm website build | |
- name: Read versions | |
id: version-check | |
run: | | |
OLD=$(npm view @synergycodes/overflow-ui version 2>/dev/null || echo "0.0.0") | |
NEW=$(jq -r .version packages/ui/package.json) | |
echo "old=$OLD" >> $GITHUB_OUTPUT | |
echo "new=$NEW" >> $GITHUB_OUTPUT | |
- name: Conditionally build & publish | |
run: | | |
echo "Old version: ${{ steps.version-check.outputs.old }}" | |
echo "New version: ${{ steps.version-check.outputs.new }}" | |
if [ "${{ steps.version-check.outputs.new }}" != "${{ steps.version-check.outputs.old }}" ]; then | |
echo "Versions differ. Proceeding with build and publish." | |
pnpm ui build | |
cd packages/ui | |
# Check if version contains "beta" | |
if [[ "${{ steps.version-check.outputs.new }}" == *"beta"* ]]; then | |
echo "Publishing @synergycodes/overflow-ui@${{ steps.version-check.outputs.new }} with 'beta' tag…" | |
pnpm publish --tag beta --access public --no-git-checks | |
echo "Adding 'latest' tag to beta version…" | |
# INFO: The line below marks each beta version as latest. Once we publish stable version we should remove it | |
npm dist-tag add @synergycodes/overflow-ui@${{ steps.version-check.outputs.new }} latest | |
else | |
echo "Publishing @synergycodes/overflow-ui@${{ steps.version-check.outputs.new }} with 'latest' tag…" | |
pnpm publish --access public --no-git-checks | |
fi | |
else | |
echo "Version unchanged. Skipping build and publish." | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Deploy Documentation to Production | |
uses: Azure/static-web-apps-deploy@v1 | |
with: | |
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
output_location: ${{ env.OUTPUT_LOCATION }} | |
app_location: ${{ env.APP_LOCATION }} | |
app_build_command: "pnpm website build" | |
action: "upload" | |
skip_api_build: true | |
deployment_environment: "production" | |
env: | |
CUSTOM_BUILD_COMMAND: npm i -g corepack@latest && corepack prepare && pnpm install --frozen-lockfile && pnpm ui build && pnpm website build | |
ENABLE_NODE_MONOREPO_BUILD: true | |
NODE_VERSION: 22 |