go-tools/.gitea/workflows/build-test.yml

71 lines
1.9 KiB
YAML
Raw Normal View History

2023-09-29 13:13:09 -06:00
name: Go Test
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- uses: actions/checkout@v3
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.1
- name: Test
run: go test -v -race -skip '^TestE2E|TestMain' ./...
- run: echo "🍏 This job's status is ${{ job.status }}."
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
2023-09-29 13:13:09 -06:00
2023-09-29 13:13:09 -06:00
- run: apt-get -y install ansible
2023-09-29 13:13:09 -06:00
2023-09-29 13:13:09 -06:00
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.1
- name: Build
2023-09-29 13:13:09 -06:00
run: go build -ldflags "-s -w" -o ./build/ev ./cmd/ev
2023-09-29 13:13:09 -06:00
- name: Compress
2023-09-29 13:13:09 -06:00
uses: https://git.sour.is/actions/ghaction-upx@v2.4.0
2023-09-29 13:13:09 -06:00
with:
version: latest
files: |
2023-09-29 13:13:09 -06:00
./build/ev
2023-09-29 13:13:09 -06:00
args: -fq
2023-09-29 13:13:09 -06:00
- name: Deploy
2023-09-29 13:13:09 -06:00
uses: https://git.sour.is/actions/action-ansible-playbook@v2
2023-09-29 13:13:09 -06:00
with:
2023-09-29 13:13:09 -06:00
playbook: ${{ gitea.workspace }}/.ansible/playbook.yml
2023-09-29 13:13:09 -06:00
key: ${{secrets.deploy_ssh}}
options: |
2023-09-29 13:13:09 -06:00
--inventory .ansible/inventory
2023-09-29 13:13:09 -06:00
--become
--become-method sudo
--user deploy
--ssh-common-args '-p 65535'
2023-09-29 13:13:09 -06:00
- run: echo "🍏 This job's status is ${{ job.status }}."