|
1 | | ---- |
2 | | -name: CI & Release |
3 | | - |
4 | | -# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string |
5 | | -run-name: >- |
6 | | - ${{ |
7 | | - inputs.release && inputs.test && 'Build ➤ Test ➤ Publish to NPM' || |
8 | | - inputs.release && !inputs.test && 'Build ➤ Skip Tests ➤ Publish to NPM' || |
9 | | - github.event_name == 'workflow_dispatch' && inputs.test && 'Build ➤ Test' || |
10 | | - github.event_name == 'workflow_dispatch' && !inputs.test && 'Build ➤ Skip Tests' || |
11 | | - '' |
12 | | - }} |
| 1 | +name: CI |
13 | 2 |
|
14 | 3 | on: |
15 | 4 | pull_request: |
16 | 5 | push: |
17 | 6 | branches: [main] |
18 | | - workflow_dispatch: |
19 | | - inputs: |
20 | | - test: |
21 | | - description: 'Run tests' |
22 | | - required: true |
23 | | - default: true |
24 | | - type: boolean |
25 | | - release: |
26 | | - description: 'Publish new release' |
27 | | - required: true |
28 | | - default: false |
29 | | - type: boolean |
30 | 7 |
|
31 | 8 | concurrency: |
32 | 9 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
|
46 | 23 |
|
47 | 24 | test: |
48 | 25 | needs: build |
49 | | - if: github.event.inputs.test != 'false' |
50 | 26 | runs-on: ${{ matrix.os }} |
51 | 27 | strategy: |
52 | 28 | fail-fast: false |
|
71 | 47 | cache: npm |
72 | 48 | - run: npm i |
73 | 49 | - run: npm test |
74 | | - |
75 | | - release: |
76 | | - needs: [build, test] |
77 | | - # only run if opt-in during workflow_dispatch |
78 | | - if: always() && github.event.inputs.release == 'true' && needs.build.result != 'failure' && needs.test.result != 'failure' && needs.test.result != 'cancelled' |
79 | | - runs-on: ubuntu-latest |
80 | | - permissions: |
81 | | - id-token: write |
82 | | - steps: |
83 | | - - uses: actions/create-github-app-token@v2 |
84 | | - id: app-token |
85 | | - with: |
86 | | - app-id: ${{ secrets.ECOSPARK_APP_ID }} |
87 | | - private-key: ${{ secrets.ECOSPARK_APP_PRIVATE_KEY }} |
88 | | - - uses: actions/checkout@v5 |
89 | | - with: |
90 | | - # Need all history to analyze commits since last release |
91 | | - fetch-depth: 0 |
92 | | - # Uses generated token to allow pushing commits back |
93 | | - token: ${{ steps.app-token.outputs.token }} |
94 | | - # Make sure GITHUB_TOKEN will not be persisted in repo's config |
95 | | - persist-credentials: false |
96 | | - - uses: actions/setup-node@v4 |
97 | | - with: |
98 | | - cache: npm |
99 | | - node-version: lts/* |
100 | | - registry-url: 'https://registry.npmjs.org' |
101 | | - # Ensure npm 11.5.1 or later is installed |
102 | | - - name: Update npm |
103 | | - run: npm install -g npm@latest |
104 | | - - run: npm ci |
105 | | - # Branches that will release new versions are defined in .releaserc.json |
106 | | - - run: npm run release |
107 | | - env: |
108 | | - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
0 commit comments