Skip to content

Commit

Permalink
add main workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Oct 25, 2024
1 parent 790eccb commit 1a1b287
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 46 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Main Workflow
on:
push:
branches:
- main
pull_request:

jobs:
determine-workflow:
name: Determine workflow path
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.determine-should-release.outputs.should-release }}
steps:
- uses: actions/checkout@v4

- id: determine-should-release
uses: ./.github/actions/should_release

release:
needs: determine-workflow
if: ${{ needs.determine-workflow.outputs.should-release == 'true' }}
uses: ./.github/workflows/release.yml
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}

test:
needs: determine-workflow
if: ${{ needs.determine-workflow.outputs.should-release == 'false' }}
uses: ./.github/workflows/test.yml
38 changes: 13 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
name: Release
on:
push:
branches:
- main
pull_request: # Runs on pull requests to any branch
jobs:
determine-should-release:
if: ${{ startsWith(github.head_ref, 'release--') }}
name: Determine if this branch should release
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.determine-should-release.outputs.should-release }}
steps:
- uses: actions/checkout@v4

- id: determine-should-release
uses: ./.github/actions/should_release
workflow_call:
secrets:
GPG_SIGNING_KEY:
required: true
GH_TOKEN:
required: true
NPM_TOKEN:
required: true
LASTMJS_GITHUB_TOKEN:
required: true

jobs:
get-test-infos:
needs: determine-should-release
if: ${{ startsWith(github.head_ref, 'release--') && needs.determine-should-release.outputs.should-release }}
name: Get test infos
runs-on: ubuntu-latest
outputs:
Expand All @@ -41,16 +34,11 @@ jobs:
release:
name: Deploy release
# Only run this job if it's a release branch. This job will run instead of run-tests and will automatically publish another commit which will be tested
if: ${{ needs.determine-should-release.outputs.should-release == 'true' }}

needs:
- determine-should-release
- get-test-infos

uses: ./.github/workflows/release_parallel.yml
secrets:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} # All commits must be verified
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
LASTMJS_GITHUB_TOKEN: ${{ secrets.LASTMJS_GITHUB_TOKEN }}
23 changes: 2 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,10 @@
# This GitHub Action takes care of deploying to npm and GitHub.

name: Test

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

jobs:
determine-should-run-tests:
name: Determine if tests should run
runs-on: ubuntu-latest
outputs:
# If the branch should release then it shouldn't run tests.
should-run-tests: ${{ steps.determine-should-run-tests.outputs.should-release == 'false' }}
steps:
- uses: actions/checkout@v4

- id: determine-should-run-tests
uses: ./.github/actions/should_release

set-exclude-dirs:
name: Set exclude directories
runs-on: ubuntu-latest
Expand Down Expand Up @@ -103,10 +87,7 @@ jobs:
run-tests:
name: ${{ matrix.test_group.name }}
needs:
- determine-should-run-tests
- set-exclude-dirs
if: ${{ needs.determine-should-run-tests.outputs.should-run-tests == 'true' }}
needs: set-exclude-dirs
strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit 1a1b287

Please sign in to comment.