Skip to content

fix: separate dev and prod package releases #533

fix: separate dev and prod package releases

fix: separate dev and prod package releases #533

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: "Git tag to deploy"
required: true
default: "last-release"
environment:
description: "Select deployment environment"
required: true
type: choice
options:
- prod
- dev
default: dev
permissions:
contents: write
pull-requests: write
repository-projects: write
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.REPO_PAT }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Configure git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Build and test
run: |
corepack enable
pnpm install --frozen-lockfile --ignore-scripts
pnpm nx affected --base=last-release -t format:check --parallel=3
pnpm nx affected --base=last-release -t build --parallel=3
pnpm nx affected --base=last-release -t lint --parallel=3
pnpm nx affected --base=last-release -t test --parallel=3
- name: Create Figma tokens flat artifact
uses: actions/upload-artifact@v4
with:
name: figma-tokens
path: packages/design/figma/dist/tokens
- name: Create Figma tokens flat artifact
uses: actions/upload-artifact@v4
with:
name: figma-tokens-flat
path: packages/design/figma/dist/tokens-flat
- name: Publish new ALPHA version on NPM
if: github.ref == 'refs/heads/main' && github.event.inputs.environment == 'dev'
run: |
pnpm nx affected --base=last-release -t version --parallel=1 --releaseAs=prerelease --preid=alpha
env:
GITHUB_TOKEN: ${{ secrets.REPO_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish new PROD version on NPM
if: github.ref == 'refs/heads/main' && github.event.inputs.environment == 'prod'
run: |
pnpm nx affected --base=last-release -t version --parallel=1
env:
GITHUB_TOKEN: ${{ secrets.REPO_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup AWS ECR Details
if: github.ref == 'refs/heads/main'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Sign in to Amazon ECR
if: github.ref == 'refs/heads/main'
id: ecr-sign-in
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
- name: Build and push docker
if: github.ref == 'refs/heads/main'
env:
ECR_REGISTRY: ${{ steps.ecr-sign-in.outputs.registry }}
ECR_REPOSITORY: life-events-design-system
IMAGE_TAG: latest # TODO: env vars in Nx project.json
run: |
pnpm nx affected --base=last-release -t docker --parallel=1
- name: Deploy to ECS
if: github.ref == 'refs/heads/main'
env:
CLUSTER_NAME: life-events-ecs
SERVICE_NAME: design-system-service
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment
- name: Tag last-release
if: github.ref == 'refs/heads/main'
shell: bash
run: |
git tag -f last-release
git push origin last-release --force