-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (94 loc) · 2.77 KB
/
build-deploy.yaml
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
name: Build and Deploy
on:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm install
- name: Run lint
run: npm run lint
test:
runs-on: ubuntu-latest
needs: [lint]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: node_modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm install
- name: Run Unit tests
run: npm run test
build:
runs-on: ubuntu-latest
needs: [test]
permissions:
packages: write
steps:
- uses: actions/checkout@v4
- name: Generate calver tag
id: calver
run: |
echo "tag=$(date +%Y-%m)-${{ github.job }}" >> $GITHUB_OUTPUT
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker metadata
id: image_metadata
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/collinmurd/virtual-guillotine
tags: |
type=raw,value=${{ steps.calver.outputs.tag }}
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Docker build and push
uses: docker/build-push-action@v6
with:
file: Dockerfile
tags: ${{ steps.image_metadata.outputs.tags }}
labels: ${{ steps.image_metadata.outputs.labels }}
platforms: linux/amd64,linux/arm64
push: true
deploy:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Configure ssh key
env:
PRIVATE_KEY: ${{ secrets.GUILLOTINE_PRIVATE_KEY }}
run: |
echo "$PRIVATE_KEY" > id_rsa_guillotine
chmod 600 id_rsa_guillotine
- name: Docker Compose up
env:
HOST: "149.130.209.48"
run: |
ssh -i id_rsa_guillotine -o "StrictHostKeyChecking no" guillotine@$HOST "
curl -o pull_sleeper_players.sh https://raw.githubusercontent.com/collinmurd/virtual_guillotine/main/bin/pull_sleeper_players.sh
curl -o docker-compose.yaml https://raw.githubusercontent.com/collinmurd/virtual_guillotine/main/docker-compose.yaml
docker compose pull
docker compose up -d
"