-
Notifications
You must be signed in to change notification settings - Fork 11
87 lines (82 loc) · 3.03 KB
/
ci.yml
File metadata and controls
87 lines (82 loc) · 3.03 KB
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
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Run Common Setup
uses: ./.github/actions/setup
- name: Cache Go tools
uses: actions/cache@v5
with:
path: |
~/go/bin/golangci-lint
~/go/bin/vacuum
key: go-tools-${{ runner.os }}-${{ hashFiles('go.mod') }}
restore-keys: go-tools-${{ runner.os }}-
- name: Install Go tools
run: |
test -x ~/go/bin/golangci-lint || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
test -x ~/go/bin/vacuum || go install github.com/daveshanley/vacuum@latest
- name: Build Templates
run: just build-templates
- name: Run Linter
run: just lint
- name: Validate OpenAPI Spec
run: just check-spec
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Run Common Setup
uses: ./.github/actions/setup
- name: Build Templates
run: just build-templates
- name: Run Tests
run: just test
build:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Run Common Setup
uses: ./.github/actions/setup
- name: Build Application
run: just build
- name: Upload binary
uses: actions/upload-artifact@v7
if: github.ref == 'refs/heads/main'
with:
name: pkgstatsd
path: pkgstatsd
retention-days: 7
deploy:
runs-on: ubuntu-latest
needs: [build]
if: github.ref == 'refs/heads/main'
steps:
- name: Download binary
uses: actions/download-artifact@v8
with:
name: pkgstatsd
- name: Deploy
env:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
KNOWN_HOSTS: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
DEPLOY_SSH_PORT: ${{ vars.DEPLOY_SSH_PORT }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_ed25519
chmod +x pkgstatsd
rsync -e "ssh -p ${DEPLOY_SSH_PORT}" pkgstatsd pkgstatsd@${DEPLOY_HOST}:/opt/pkgstatsd/pkgstatsd.new
ssh -p "${DEPLOY_SSH_PORT}" pkgstatsd@${DEPLOY_HOST} "mv /opt/pkgstatsd/pkgstatsd.new /opt/pkgstatsd/pkgstatsd"