-
Notifications
You must be signed in to change notification settings - Fork 90
71 lines (56 loc) · 1.72 KB
/
ci.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
name: CI
# This action works with pull requests and pushes
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
# We do not need Husky hooks installed for this workflow.
HUSKY: 0
IMAGENAME: registry.digitalocean.com/nsgcr/netrunner-cards-json
jobs:
format_and_lint_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Format Check
run: npm run format-check
- name: Lint
run: npm run lint
- name: Test
run: npm run test
build_and_push:
name: Build docker image
needs: [format_and_lint_and_test]
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
run: docker build -t $IMAGENAME:latest .
- name: Install doctl
if: github.ref == 'refs/heads/main'
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
if: github.ref == 'refs/heads/main'
run: doctl registry login --expiry-seconds 600
- name: Tag image with run id
if: github.ref == 'refs/heads/main'
run:
docker tag $IMAGENAME:latest $IMAGENAME:${{ github.run_id }}
- name: Push image to DO Container Registry
if: github.ref == 'refs/heads/main'
run: docker push $IMAGENAME:${{ github.run_id }} && docker push $IMAGENAME:latest