-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (80 loc) · 2.81 KB
/
test-and-publish.yml
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
name: test and publish
on: push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "18.13"
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Install
run: npm ci
- name: Run format test
run: npm run test:format
- name: Run license test
run: npm run test:license
- name: Client - Install
run: cd client && npm ci
# - name: Client - audit
# run: cd client && npm run test:audit
- name: Client - Run lint test
run: cd client && npm run test:lint
- name: Client - Run types test
run: cd client && npm run test:types
test-e2e:
name: test e2e
runs-on: ubuntu-latest
steps:
- name: Authenticate with private NPM package
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- uses: actions/checkout@v2
- name: build + run app in docker-compose
run: docker-compose up -d
- name: check services running
run: docker ps
- name: cypress - run tests
run: make test-e2e-exec
publish-check:
name: publish check
needs:
- test
- test-e2e
runs-on: ubuntu-latest
outputs:
is_release: ${{ steps.is_release.outputs.is_release }}
steps:
- id: is_release
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]*)?$ ]]; then
echo ::set-output name=is_release::true
fi
build-and-publish:
name: build + push docker image
runs-on: ubuntu-latest
needs:
- publish-check
- test
- test-e2e
if: needs.publish-check.outputs.is_release || github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2
- name: docker tag
id: tag
run: |
IMAGE_TAG=${GITHUB_SHA}
echo ::set-output name=image_tag::${IMAGE_TAG}
- name: docker login
run: docker login -u ${{ secrets.DOCKER_LOGIN }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Docker build
run: export DOCKER_IMAGE=mentorpal/mentor-client:${{ steps.tag.outputs.image_tag }} && make docker-build
- name: docker tag release as version
if: needs.publish-check.outputs.is_release == 'true'
run: docker tag "mentorpal/mentor-client:${{ steps.tag.outputs.image_tag }}" "mentorpal/mentor-client:${GITHUB_REF#refs/tags/}"
- name: docker tag main as latest
if: github.ref == 'refs/heads/main'
run: docker tag "mentorpal/mentor-client:${{ steps.tag.outputs.image_tag }}" "mentorpal/mentor-client:latest"
- name: docker push
run: docker push --all-tags mentorpal/mentor-client