-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 3.01 KB
/
command-backend-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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: command-backend-pipeline
on:
push:
branches:
- "stable"
- "main"
pull_request:
branches: [main]
paths:
- "backend/command/**"
- ".github/workflows/command-backend-ci.yml"
jobs:
setup:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: backend/command
steps:
- name: Checkout
uses: actions/checkout@v3
- name: install npm dependencies
run: npm ci --no-audit --cache ~/.npm
- name: Cache
id: cache
uses: actions/cache@v3
with:
path: ~/.npm
key: node-modules-${{ hashFiles('package-lock.json') }}
tests:
runs-on: ubuntu-latest
needs: setup
defaults:
run:
shell: bash
working-directory: backend/command
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Load cache
id: cache
uses: actions/cache@v3
with:
path: ~/.npm
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: node modules
run: npm ci --audit:false --cache ~/.npm --prefer-offline
- name: tests
run: npm run test:ci
- name: codecov upload
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: .coverage/coverage-final.json
flags: command-backend
docker-build-and-push:
runs-on: ubuntu-latest
needs: tests
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Arm support
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Extract branch name and replace / with _ as slashes are invalid as image tags
- name: Extract branch name
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/} | tr '/' '_')"
id: extract_branch
- name: Login to GitHub Container Registry
uses: docker/#-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./backend/command
tags: ghcr.io/world-wide-weights/command-backend:${{ steps.extract_branch.outputs.branch }}
platforms: linux/amd64,linux/arm64
push: true
labels: |
org.opencontainers.image.source: https://github.com/world-wide-weights/wwweights
org.opencontainers.image.description: wwweights command backend for handling user requests
redeploy:
if: github.ref == 'refs/heads/stable'
needs: docker-build-and-push
runs-on: ubuntu-latest
env:
deploy_secret: ${{ secrets.DEPLOY_SECRET }}
webhook: ${{ secrets.COMMAND_REDEPLOY_WEBHOOK }}
steps:
- name: trigger redeploy
run: |
curl -X GET -H "x-deploy-secret: $deploy_secret" $webhook