refactor: Update CI configuration in .github/workflows/pipeline.yaml #43
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: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
jobs: | |
check-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
ui-changed: ${{ steps.check.outputs.ui-changed }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Check for changes in packages/ui | |
id: check | |
run: | | |
echo "Checking for changes in packages/ui..." | |
if git diff --name-only HEAD^ HEAD | grep -q '^packages/ui/'; then | |
echo "ui-changed=true" >> $GITHUB_ENV | |
else | |
echo "ui-changed=false" >> $GITHUB_ENV | |
fi | |
shell: bash | |
pol-ui: | |
name: 🧪 Pol-UI (Lint, Build, Test, Deploy) | |
needs: check-changes | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' # Ejecuta siempre que sea en la rama `main` | |
steps: | |
- name: 👍 Checkout | |
uses: actions/checkout@v3 | |
- name: 💡 Install PNPM | |
run: npm install -g pnpm | |
- name: ❇️ Setup node.js LTS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: lts/* | |
cache: "pnpm" | |
- name: 📥 Install Dependencies | |
run: pnpm install | |
- name: 💅 Lint | |
run: pnpm lint | |
- name: 🧪 Unit Tests and coverage | |
run: pnpm test | |
- name: setup git config | |
run: | | |
git config user.name "Bot" | |
git config user.email "" | |
- name: Get run number | |
id: run_number | |
run: echo "RUN_NUMBER=${{ github.run_number }}" >> $GITHUB_ENV | |
- name: Update version in package.json | |
run: | | |
cd packages/ui | |
node -e " | |
let pkg = require('./package.json'); | |
let versionParts = pkg.version.split('.'); | |
versionParts[2] = '${{ env.RUN_NUMBER }}'; | |
pkg.version = versionParts.join('.'); | |
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2)); | |
" | |
shell: bash | |
- name: 🍀 Publish to NPM | |
if: github.ref == 'refs/heads/main' | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc | |
cd packages/ui | |
pnpm publish --no-git-checks | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |