-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (107 loc) · 3.67 KB
/
main.yml
File metadata and controls
108 lines (107 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# secrets.GITHUB_TOKEN is provided to each job by default, lifetime: 60minutes.
# See https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token
name: Lint, Test, Build and optionally Publish
on:
# push only for branches (ignore tags)
push:
branches:
- 'main'
tags-ignore:
- '**'
# pull request only for branches (ignore tags)
pull_request:
branches:
- '**'
tags-ignore:
- '**'
jobs:
checkExecution:
runs-on: ubuntu-latest
outputs:
shouldExecute: ${{ steps.stepCheckExecution.outputs.shouldExecute }}
steps:
- id: stepCheckExecution
name: Check for execution
uses: shiftcode/github-action-skip@9d4a90c80567f59dfaacf18fe703a324583c742e #v5.0.0
with:
skipOnCommitMsg: '[skip_build]'
githubToken: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
needs: checkExecution
# only execute if not skipped by commit message
if: needs.checkExecution.outputs.shouldExecute == 'true'
strategy:
matrix:
# Test with Node.js 24 and v25
node:
- 24
- 25
name: Node.js v${{ matrix.node }}
steps:
# checkout branch
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd #v5.0.1
# setup node and dependency cache
- name: Setup Node and NPM Cache
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5.0.0
with:
node-version: ${{ matrix.node }}
cache: 'npm'
# install dependencies
- name: Install
run: HUSKY=0 npm ci
# test
- name: Test
run: npm run test:ci
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs: [checkExecution, test]
# only execute if not skipped by commit message
if: needs.checkExecution.outputs.shouldExecute == 'true'
steps:
# checkout branch
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd #v5.0.1
with:
# 0 indicates all history, because publish requires tag information
fetch-depth: 0
# do not persist credentials to avoid issues with protected branches (e.g. when pushing version-bump commit after merging PR)
persist-credentials: false
# setup node and dependency cache
- name: Setup Node and NPM Cache
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5.0.0
with:
node-version-file: .nvmrc
cache: 'npm'
# install dependencies
- name: Install
run: HUSKY=0 npm ci
# build lint plugins before linting
- name: Build lint plugins
run: npm run build:lint:ci
# check formatting
- name: Check Formatting
run: npm run format:ci
# lint
- name: Lint
run: npm run lint:ci
# build
- name: Build
run: npm run build:ci
# publish
- name: Publish
run: |
npm config set //npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}
git config user.email "actions@github.com"
git config user.name "Github Actions"
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/shiftcode/sc-commons-public.git
npm run publish-libs
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
# necessary to commit on protected branch after merging
# and to run actions after version-bump commit (otherwise we can't create rules for merging as no workflows run after GITHUB_TOKEN commits)
GH_TOKEN: ${{ secrets.GH_TOKEN }}