-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (78 loc) · 2.98 KB
/
ci.yml
File metadata and controls
83 lines (78 loc) · 2.98 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
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 golangci-lint
uses: actions/cache@v5
with:
path: ~/go/bin/golangci-lint
key: golangci-lint-${{ runner.os }}-${{ hashFiles('go.mod') }}
restore-keys: golangci-lint-${{ runner.os }}-
- name: Install golangci-lint
run: test -x ~/go/bin/golangci-lint || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
- name: Build Templates
run: just build-templates
- name: Run Linter
run: just lint
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
# TODO: remove go branch condition once merged into main
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/go'
with:
name: archded
path: archded
retention-days: 7
deploy:
runs-on: ubuntu-latest
needs: [build]
# TODO: remove go branch condition once merged into main
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/go'
steps:
- name: Download binary
uses: actions/download-artifact@v8
with:
name: archded
- 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 archded
rsync -e "ssh -p ${DEPLOY_SSH_PORT}" archded archded@${DEPLOY_HOST}:/opt/archded/archded.new
ssh -p "${DEPLOY_SSH_PORT}" archded@${DEPLOY_HOST} "mv /opt/archded/archded.new /opt/archded/archded"