Skip to content

Commit 33be1c7

Browse files
committed
CI: use standard Github Action templates
A lot of our repositories have diverged from our intended template, so this copies a temlated version over whatever was here before Connects pelias/pelias#951
1 parent f961f65 commit 33be1c7

File tree

3 files changed

+31
-32
lines changed

3 files changed

+31
-32
lines changed

.github/workflows/_test.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Unit Tests
2+
on: workflow_call
3+
jobs:
4+
unit-tests:
5+
runs-on: '${{ matrix.os }}'
6+
strategy:
7+
matrix:
8+
os:
9+
- ubuntu-22.04
10+
node-version: [ 18.x, 20.x, 22.x ]
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: 'Install node.js ${{ matrix.node-version }}'
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: '${{ matrix.node-version }}'
17+
- name: Run unit tests
18+
run: |
19+
[[ -f ./bin/ci-setup ]] && ./bin/ci-setup
20+
npm install
21+
npm run ci

.github/workflows/pull_request.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: Continuous Integration
2+
on: pull_request
3+
jobs:
4+
unit-tests:
5+
# only run this job for forks
6+
if: github.event.pull_request.head.repo.full_name != github.repository
7+
uses: ./.github/workflows/_test.yml

.github/workflows/push.yml

+3-32
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,17 @@ name: Continuous Integration
22
on: push
33
jobs:
44
unit-tests:
5-
runs-on: '${{ matrix.os }}'
6-
strategy:
7-
matrix:
8-
os:
9-
- ubuntu-22.04
10-
node-version: [ 18.x, 20.x, 22.x ]
11-
steps:
12-
- uses: actions/checkout@v4
13-
- name: 'Install node.js ${{ matrix.node-version }}'
14-
uses: actions/setup-node@v4
15-
with:
16-
node-version: '${{ matrix.node-version }}'
17-
- name: Run unit tests
18-
run: |
19-
npm install
20-
npm run ci
5+
uses: ./.github/workflows/_test.yml
216
npm-publish:
227
needs: unit-tests
23-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
8+
if: github.ref == 'refs/heads/master' && needs.unit-tests.result == 'success'
249
runs-on: ubuntu-22.04
2510
steps:
2611
- uses: actions/checkout@v4
2712
- name: Install Node.js
2813
uses: actions/setup-node@v4
2914
with:
30-
node-version: 16.x
15+
node-version: 20.x
3116
- name: Run semantic-release
3217
env:
3318
GH_TOKEN: ${{ secrets.GH_SEMANTIC_RELEASE_TOKEN }}
@@ -36,17 +21,3 @@ jobs:
3621
if [[ -n "$GH_TOKEN" && -n "$NPM_TOKEN" ]]; then
3722
curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash -
3823
fi
39-
build-docker-images:
40-
# run this job if the unit tests passed and the npm-publish job was a success or was skipped
41-
# note: github actions won't run a job if you don't call one of the status check functions, so `always()` is called since it evalutes to `true`
42-
if: ${{ always() && needs.unit-tests.result == 'success' && (needs.npm-publish.result == 'success' || needs.npm-publish.result == 'skipped') }}
43-
needs: [unit-tests, npm-publish]
44-
runs-on: ubuntu-22.04
45-
steps:
46-
- uses: actions/checkout@v4
47-
- name: Build Docker images
48-
env:
49-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
50-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
51-
run: |
52-
curl "https://raw.githubusercontent.com/pelias/ci-tools/master/build-docker-images.sh" | bash -

0 commit comments

Comments
 (0)