-
Notifications
You must be signed in to change notification settings - Fork 92
74 lines (55 loc) · 1.92 KB
/
docker-cicd.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
name: docker-cicd
on:
pull_request:
push:
branches:
- main
env:
# We do not need Husky hooks installed for this workflow.
HUSKY: 0
jobs:
format_and_lint_and_test:
name: Format, Lint, Test
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: "18.x"
- 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: Docker build and push
needs: format_and_lint_and_test
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
run: docker build -t nsgcr/netrunner-cards-json .
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DO Container Registry
run: doctl registry login --expiry-seconds 600
- name: Tag image with run id
run:
docker tag nsgcr/netrunner-cards-json registry.digitalocean.com/nsgcr/netrunner-cards-json:${{ github.run_id }}
- name: Tag image with latest
run:
docker tag nsgcr/netrunner-cards-json registry.digitalocean.com/nsgcr/netrunner-cards-json:latest
- name: Push run id tag to DO Container Registry
run: docker push registry.digitalocean.com/nsgcr/netrunner-cards-json:${{ github.run_id }}
- name: Push latest tag to DO Container Registry
run: docker push registry.digitalocean.com/nsgcr/netrunner-cards-json:latest