Skip to content

Commit

Permalink
ci(.github): split out steps into separate actions, consolidate push …
Browse files Browse the repository at this point in the history
…and pull files
  • Loading branch information
waldronmatt committed Apr 18, 2024
1 parent 63afc20 commit 87033f6
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 135 deletions.
9 changes: 9 additions & 0 deletions .github/actions/checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Checkout Code'

runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
9 changes: 9 additions & 0 deletions .github/actions/install-deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Install Playwright and Dependencies'

runs:
using: 'composite'
steps:
# - name: Install Playwright Browsers
# run: npx playwright install --with-deps
- name: Install dependencies
run: pnpm install
27 changes: 27 additions & 0 deletions .github/actions/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Release'

inputs:
github-token:
required: true
npm-token:
required: true

runs:
using: 'composite'
steps:
- name: Config Git User
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
env:
GITHUB_TOKEN: ${{ inputs.github-token }}

- name: NPM Registry Authentication
run: |
npm config set '//registry.npmjs.org/:_authToken' ${{ inputs.npm-token }}
- name: Bump Versions
run: pnpm version:ci

- name: Publish Packages
run: pnpm publish:ci
10 changes: 10 additions & 0 deletions .github/actions/run-affected.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'Run NX Affected'

runs:
using: 'composite'
steps:
- name: NX Affected
uses: nrwl/nx-set-shas@v4

- name: Build, Lint, Test
run: npx nx affected -t build,lint,test --parallel=3
11 changes: 11 additions & 0 deletions .github/actions/setup-node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Setup Node.js'
inputs:
node-version:
required: true
runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
28 changes: 28 additions & 0 deletions .github/actions/setup-pnpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'Setup pnpm and Cache'

inputs:
pnpm-version:
required: true

runs:
using: 'composite'
steps:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ inputs.pnpm-version }}
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
46 changes: 46 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CICD Workflow

on:
push:
branches:
- main
pull_request:
branches:
- main

env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}

jobs:
build-and-test:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [20]
pnpm-version: [8]
steps:
- name: Checkout Code
uses: waldronmatt/groundwork/.github/actions/checkout.yml

- name: Setup Node.js
uses: waldronmatt/groundwork/.github/actions/setup-node.yml
with:
node-version: ${{ matrix.node-version }}

- name: Setup pnpm and Cache
uses: waldronmatt/groundwork/.github/actions/setup-pnpm.yml
with:
pnpm-version: ${{ matrix.pnpm-version }}

- name: Install Playwright and Dependencies
uses: waldronmatt/groundwork/.github/actions/install-deps.yml

- name: Run NX Affected Commands
uses: waldronmatt/groundwork/.github/actions/run-affected.yml

- name: Publish Packages
if: github.event_name == 'push'
uses: waldronmatt/groundwork/.github/actions/publish.yml
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
npm-token: ${{ secrets.NPM_TOKEN }}
58 changes: 0 additions & 58 deletions .github/workflows/pull.yml

This file was deleted.

77 changes: 0 additions & 77 deletions .github/workflows/push.yml

This file was deleted.

0 comments on commit 87033f6

Please sign in to comment.