-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 1.74 KB
/
tests.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
# Copyright © 2016-2024 Endless OS Foundation LLC
# SPDX-License-Identifier: GPL-2.0-or-later
name: EOS Activation Server Tests
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
env:
IMAGE: endlessm/eos-activation-server
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and export to Docker
uses: docker/build-push-action@v6
with:
context: .
load: true
pull: true
tags: test-server:latest
- name: Run Redis
run: docker run -d --rm --network=host --name=redis redis:5-alpine
- name: Run server
run: docker run -d --rm --network=host --name=server test-server:latest
- name: Run tests
run: docker run --rm --network=host test-server:latest npm test
- name: Stop server
run: docker stop server
- name: Stop Redis
run: docker stop redis
- name: Build and push to Docker Hub
uses: docker/build-push-action@v6
with:
context: .
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}