Skip to content

Commit

Permalink
fix(ci): updates github actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
csantiago132 committed Oct 3, 2024
1 parent fd49a2f commit 21d2b1c
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 166 deletions.
22 changes: 22 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Install'
description: 'Sets up Node, and installs dependencies'

runs:
using: 'composite'
steps:
- name: Set up PNPM
uses: pnpm/action-setup@v3
with:
version: '7'

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm

- name: Install dependencies
shell: bash
run: |
corepack enable
pnpm install
18 changes: 18 additions & 0 deletions .github/actions/lint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Lint Code'
description: 'Runs Commitlint, ESLint, and Prettier to ensure code quality.'

runs:
using: 'composite'
steps:
- name: Run Commitlint
shell: bash
run: |
git log -1 --pretty=%B | pnpm exec commitlint
- name: Run ESLint
shell: bash
run: pnpm eslint . --max-warnings=0

- name: Run Prettier
shell: bash
run: pnpm prettier --check .
25 changes: 0 additions & 25 deletions .github/lib/dependencies.workflow.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/lib/linter.workflow.yml

This file was deleted.

87 changes: 0 additions & 87 deletions .github/lib/release.workflow.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/ci.documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }} # Ensure access to private repo
fetch-depth: 0

- name: Install Dependencies
uses: ./lib/actions/install-dependencies

- name: Run Lint Checks
uses: ./.github/actions/lint

- name: Build docs using Writerside Docker builder
uses: JetBrains/writerside-github-action@v4
with:
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/ci.lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:
id-token: write

concurrency:
group: 'pages'
group: 'code-quality-${{ github.ref }}'
cancel-in-progress: false

on:
Expand All @@ -21,15 +21,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Install Dependencies
uses: ./.github/lib/dependencies.workflow.yml

- name: Code Quality
uses: ./.github/lib/linter.workflow.yml

uses: ./.github/actions/install

- name: Run Lint Checks
uses: ./.github/actions/lint
77 changes: 66 additions & 11 deletions .github/workflows/ci.release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: Call Release Workflow
name: Release Workflow

permissions:
pull-requests: write
contents: write
pages: write
id-token: write

on:
push:
Expand All @@ -10,19 +16,68 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }} # Ensure access to private repo
fetch-depth: 0

- name: Install Dependencies
uses: ./.github/lib/dependencies.workflow.yml
uses: ./lib/actions/install-dependencies

- name: Release
uses: ./.github/lib/release.workflow.yml
with:
release-branch-prefix: 'release-'
release-label: 'release'
- name: Run Lint Checks
uses: ./.github/actions/lint

- name: Build Assets
run: ${{ inputs.build-command }}

- name: Run Semantic Release
id: semantic_release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release

- name: Create Release Branch
if: success() && steps.semantic_release.outputs.nextRelease
run: |
VERSION=${{ steps.semantic_release.outputs.nextRelease.version }}
git checkout -b ${{ inputs.release-branch-prefix }}${VERSION}
- name: Push Release Branch
if: success() && steps.semantic_release.outputs.nextRelease
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PAT_FORCE_PUSH: ${{ secrets.GH_TOKEN }}
PAT: ${{ secrets.PAT_FORCE_PUSH }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${PAT}@github.com/${{ github.repository }}.git
git push origin ${{ inputs.release-branch-prefix }}${VERSION} --force
- name: Extract Version from package.json
id: extract_version
run: |
VERSION=$(jq -r .version package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Extract Changelog
id: changelog
run: |
CHANGELOG=$(awk '/^## \[/ {print; exit}' CHANGELOG.md)
echo "changelog=$CHANGELOG" >> $GITHUB_OUTPUT
- name: Create Pull Request to Main
if: success() && steps.semantic_release.outputs.nextRelease
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: 'chore/release: ${{ steps.extract_version.outputs.version }}'
body: |
This is an automated pull request for release version `${{ steps.extract_version.outputs.version }}`.
**Changelog:**
```
${{ steps.changelog.outputs.changelog }}
```
head: ${{ inputs.release-branch-prefix }}${{ steps.extract_version.outputs.version }}
base: main
commit-message: 'chore/release: ${{ steps.extract_version.outputs.version }} [skip ci]'
labels: ${{ inputs.release-label }}

0 comments on commit 21d2b1c

Please sign in to comment.