Skip to content

Commit

Permalink
ci: align workflows standard to use the new reusable workflows and ac…
Browse files Browse the repository at this point in the history
…tions (#2007)
  • Loading branch information
YossiSaadi authored Mar 12, 2024
1 parent 0bde412 commit 100f17f
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .github/actions/determine-lerna-since-flag/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
since_flag="--since"
echo "Running on master branch, checking for all changes."
else
since_flag="--since=origin/master"
since_flag="--since=origin/master...HEAD"
echo "Not running on master branch, checking for changes since origin/master."
fi
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ on:
secrets:
npm_token:
required: true
outputs:
has_changes:
description: Whether there are any changes in the monorepo.
value: ${{ jobs.build-and-upload.outputs.has_changes }}

jobs:
build-and-upload:
name: Build and Upload
runs-on: ubuntu-latest
outputs:
has_changes: ${{ steps.check-changed-packages.outputs.has_changes }}

steps:
- uses: actions/checkout@v4
with:
Expand All @@ -17,14 +25,23 @@ jobs:
uses: ./.github/actions/setup
with:
npm_token: ${{ secrets.npm_token }}
- id: check-changed-packages
uses: ./.github/actions/check-changed-packages
- id: determine-since-flag
if: ${{ steps.check-changed-packages.outputs.has_changes == 'true' }}
uses: ./.github/actions/determine-lerna-since-flag
- name: Build
if: ${{ steps.check-changed-packages.outputs.has_changes == 'true' }}
shell: bash
run: yarn lerna run build --since=origin/master --include-dependencies
env:
SINCE_FLAG: ${{ steps.determine-since-flag.outputs.since_flag }}
run: yarn lerna run build $SINCE_FLAG --include-dependencies
- name: Upload
if: ${{ steps.check-changed-packages.outputs.has_changes == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ci-builds-${{ github.run_id }}-${{ github.run_attempt }}
path: |
packages/core/dist/
packages/style/dist/
if-no-files-found: ignore
if-no-files-found: ignore
25 changes: 12 additions & 13 deletions .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
name: "Chromatic"
name: Chromatic

on: push

jobs:
chromatic-deployment:
build:
name: Build
uses: ./.github/workflows/build-and-upload.yml
secrets:
npm_token: ${{ secrets.npm_token }}

publish-chromatic:
name: Publish Chromatic
needs: build
if: ${{ needs.build.outputs.has_changes == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -13,18 +22,8 @@ jobs:
uses: ./.github/actions/setup
with:
npm_token: ${{ secrets.npm_token }}
- id: check-changed-packages
uses: ./.github/actions/check-changed-packages
- id: determine-since-flag
uses: ./.github/actions/determine-lerna-since-flag
- name: Run Build
if: ${{ steps.check-changed-packages.outputs.has_changes == 'true' }}
shell: bash
env:
SINCE_FLAG: ${{ steps.determine-since-flag.outputs.since_flag }}
run: yarn lerna run build $SINCE_FLAG --include-filtered-dependencies
- uses: ./.github/actions/download-builds
- name: Publish to Chromatic
if: ${{ steps.check-changed-packages.outputs.has_changes == 'true' }}
uses: chromaui/action@v11
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
48 changes: 0 additions & 48 deletions .github/workflows/ci.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Checks

on:
pull_request:
types: [opened, synchronize]

jobs:
build:
name: Build
uses: ./.github/workflows/build-and-upload.yml
secrets:
npm_token: ${{ secrets.npm_token }}

test:
name: Test
needs: build
if: ${{ needs.build.outputs.has_changes == 'true' }}
uses: ./.github/workflows/test.yml
secrets:
npm_token: ${{ secrets.npm_token }}
18 changes: 11 additions & 7 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ on:
- "master"

jobs:
prerelease:
build:
name: Build
if: "contains(github.event.head_commit.message, '[prerelease]')"
uses: ./.github/workflows/build-and-upload.yml
secrets:
npm_token: ${{ secrets.npm_token }}

prerelease:
name: Prerelease
needs: build
if: ${{ needs.build.outputs.has_changes == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -18,12 +27,7 @@ jobs:
with:
npm_token: ${{ secrets.npm_token }}
- uses: ./.github/actions/git-creds
- name: Check if there are changed packages
run: |
changed_packages=$(yarn -s lerna ls --since=origin/master --json --loglevel=error)
[[ $changed_packages = "[]" ]] && echo "Skipping prerelease. Nothing to prerelease as Lerna didn't detect any changes." && exit 1 || echo "Changed detected. Continuing to prerelease" && echo "$changed_packages"
- name: Build all affected packages
run: yarn lerna run build --since=origin/master --include-dependencies
- uses: ./.github/actions/download-builds
- name: Generate new versions
id: generate-versions
run: |
Expand Down
51 changes: 20 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,37 @@ name: Release new version
on: workflow_dispatch

jobs:
prerequisites:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: "Test"
command: "test"
- name: "Lint"
command: "lint"
- name: "Stylelint"
command: "stylelint"
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
name: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Setup
uses: ./.github/actions/setup
with:
npm_token: ${{secrets.npm_token}}
- name: Run ${{matrix.name}}
shell: bash
run: yarn lerna run ${{matrix.command}} --since
build:
name: Build
uses: ./.github/workflows/build-and-upload.yml
secrets:
npm_token: ${{ secrets.npm_token }}

test:
name: Test
needs: build
if: ${{ needs.build.outputs.has_changes == 'true' }}
uses: ./.github/workflows/test.yml
secrets:
npm_token: ${{ secrets.npm_token }}

release:
needs: prerequisites
name: Release
needs: [build, test]
if: ${{ needs.build.outputs.has_changes == 'true' }}
runs-on: ubuntu-latest
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Setup
uses: ./.github/actions/setup
with:
npm_token: ${{secrets.npm_token}}
npm_token: ${{ secrets.npm_token }}
- uses: ./.github/actions/git-creds
- name: Run Build
shell: bash
run: yarn lerna run build --since --include-dependencies
- uses: ./.github/actions/download-builds
- name: Generate new versions
run: yarn lerna version --exact --conventional-commits -y
- run: yarn config set registry https://registry.npmjs.org/
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Notice that for this workflow to run properly, you need to first run the build-and-upload workflow.
# This is because the test workflow depends on the build-and-upload workflow to download the builds from a previous job in the same workflow run.

name: Test & Lint

on:
workflow_call:
secrets:
npm_token:
required: true

jobs:
checks:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: "Test"
command: "test"
- name: "Lint"
command: "lint"
- name: "Stylelint"
command: "stylelint"
name: ${{ matrix.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Setup
uses: ./.github/actions/setup
with:
npm_token: ${{ secrets.npm_token }}
- id: determine-since-flag
uses: ./.github/actions/determine-lerna-since-flag
- uses: ./.github/actions/download-builds
- name: Run ${{ matrix.name }}
shell: bash
env:
SINCE_FLAG: ${{ steps.determine-since-flag.outputs.since_flag }}
run: yarn lerna run ${{ matrix.command }} $SINCE_FLAG

0 comments on commit 100f17f

Please sign in to comment.