-
Notifications
You must be signed in to change notification settings - Fork 143
106 lines (88 loc) · 3.38 KB
/
push.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
name: Build and deploy
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.19
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
mkdir -p $GOPATH/bin
export PATH=$PATH:$GOPATH/bin
- name: Build
run: go build -o dragonfly_exe -v .
- name: Vet
run: go vet ./...
- name: Formatting
run: test -z $(go fmt ./...)
- name: Staticcheck
run: |
go get honnef.co/go/tools/cmd/[email protected]
GOBIN=$PWD/bin go install honnef.co/go/tools/cmd/[email protected]
./bin/staticcheck ./...
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.19
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
mkdir -p $GOPATH/bin
export PATH=$PATH:$GOPATH/bin
- name: Build
run: go build -o dragonfly_exe -v .
- name: Set SSH info
env:
SSH_KNOWN_HOSTS: ${{ secrets.VPS_KNOWN_HOSTS }}
SSH_PRIVATE_KEY: ${{ secrets.VPS_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Stop server
env:
HOST: ${{ secrets.VPS_HOST }}
run: |
ssh -i ~/.ssh/id_rsa $HOST screen -d -R -S dragonfly -X stuff '^C'
ssh -i ~/.ssh/id_rsa $HOST rm -f dragonfly_exe
- name: Transfer executable
env:
HOST: ${{ secrets.VPS_HOST }}
run: |
scp -i ~/.ssh/id_rsa dragonfly_exe $HOST:/home/dragonfly_exe
- name: Restart server
env:
HOST: ${{ secrets.VPS_HOST }}
run: |
ssh -i ~/.ssh/id_rsa $HOST "screen -d -R -S dragonfly -X stuff '/home/dragonfly_exe\n'"
update_contributors:
name: Update Contributors
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Fetch Contributors
run: |
CONTRIBUTOR_DATA=$(curl -H "Accept: application/vnd.github+json" https://api.github.com/repos/df-mc/dragonfly/contributors?per_page=9999)
echo $CONTRIBUTOR_DATA
if [ $(echo $CONTRIBUTOR_DATA | jq type) == '"array"' ]; then echo -e "// Code generated by .github/workflows/push.yml; DO NOT EDIT\n\npackage session\n\n// enchantNames are names translated to the 'Standard Galactic Alphabet' client-side. The names generally have no meaning\n// on the vanilla server implementation, so we can sneak some easter eggs in here without anyone noticing.\nvar enchantNames = []string{"$(echo $CONTRIBUTOR_DATA | jq .[].login | sed -r -e "s/([^A-Z\"])([A-Z])/\1 \2/g" | sed "s/./\L&/g" | sort | sed -z "s/\n/,/g")"}" > server/session/enchantment_texts.go && gofmt -w server/session/enchantment_texts.go; fi
- name: Push Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "updated contributor list"