Merge branch 'main' into dependabot/npm_and_yarn/word-wrap-1.2.4 #166
Workflow file for this run
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: CICD | |
on: [push] | |
jobs: | |
Validate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone Repo | |
uses: actions/[email protected] | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: Set Up NodeJs | |
uses: actions/[email protected] | |
with: | |
node-version-file: '.nvmrc' | |
cache: npm | |
- name: Install Dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
- name: Test | |
run: npm test | |
- name: Build | |
run: npm run build | |
- name: Cache Deployment | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
uses: actions/[email protected] | |
env: | |
cache-name: deployment-cache | |
with: | |
path: './**/*' | |
key: ${{ github.event.after }} | |
CheckRelease: | |
needs: Validate | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
steps: | |
- name: Load Deployment | |
uses: actions/[email protected] | |
env: | |
cache-name: deployment-cache | |
with: | |
path: './**/*' | |
key: ${{ github.event.after }} | |
- name: Check PR Labels | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
npm run release:check | |
Deploy: | |
needs: CheckRelease | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
steps: | |
- name: Load Deployment | |
uses: actions/[email protected] | |
env: | |
cache-name: deployment-cache | |
with: | |
path: './**/*' | |
key: ${{ github.event.after }} | |
- name: Configure Git | |
env: | |
GH_EMAIL: ${{ secrets.GH_EMAIL }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
GH_USER: ${{ secrets.GH_USER }} | |
run: | | |
git config --local user.name "$GH_USER" | |
git config --local user.email "$GH_EMAIL" | |
git remote set-url origin "https://x-access-token:[email protected]/$GITHUB_REPOSITORY" | |
- name: Validate Git Connection | |
run: | | |
git ls-remote origin > /dev/null | |
- name: Create Git Release | |
run: | | |
npm run release | |
- name: Push Git Release | |
run: | | |
git push --follow-tags origin $GITHUB_REF | |
- name: Configure NPM | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
npm set "//registry.npmjs.org/:_authToken=$NPM_TOKEN" | |
- name: Publish NPM Package | |
id: publish | |
run: | | |
npm publish | |
- name: Publish Release Notes | |
env: | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
run: | | |
npm run release:post | |
- name: Revert Git Release | |
if: failure() && steps.publish.outcome == 'failure' | |
run: | | |
NEW_TAG=$(git tag --points-at HEAD) | |
git tag -d $NEW_TAG | |
git push --delete origin $NEW_TAG | |
git revert --no-commit HEAD | |
git commit -m "chore(release): Reverts failed publish $NEW_TAG [skip ci]" | |
git push origin $GITHUB_REF |