-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Deploy Github action * Upload binary via SCP * Stop service before uploading, and overwrite with new binary * Upload to tmp folder then copy * Get service status after redeploy * Upload server binary as Github actions artifact * Don't deploy on pull_request * Remove concurrency as we want record of builds from merged PRs
- Loading branch information
1 parent
a6156ae
commit 3651d5e
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: 'Build & Deploy' | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ["ubuntu-latest"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: Go version | ||
run: go version | ||
|
||
- name: Go build | ||
run: go build | ||
|
||
- run: ls -l | ||
|
||
- name: Stop service | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: sudo /usr/bin/systemctl stop qrsync_server | ||
|
||
- name: Upload binary as Github action artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: server | ||
path: ./qrsync-server | ||
|
||
- name: Upload new binary | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
source: "qrsync-server" | ||
target: /var/www/qrsync_server/tmp | ||
overwrite: true | ||
|
||
- name: Move binary from tmp folder | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: cp "/var/www/qrsync_server/tmp/qrsync-server" /var/www/qrsync_server | ||
|
||
- name: Restart service | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: sudo /usr/bin/systemctl restart qrsync_server | ||
|
||
- name: Get service status | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ${{ secrets.SSH_USERNAME }} | ||
password: ${{ secrets.SSH_PASSWORD }} | ||
port: ${{ secrets.SSH_PORT }} | ||
script: /usr/bin/systemctl status qrsync_server |