This commit is contained in:
98
.gitea/workflows/deploy.yaml
Normal file
98
.gitea/workflows/deploy.yaml
Normal file
@@ -0,0 +1,98 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- release/*
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- release/*
|
||||
|
||||
env:
|
||||
APP_NAME: "dnspod-watch"
|
||||
NAMESPACE: app
|
||||
REGISTRY: ${{ secrets.DOCKER_REGISTRY && secrets.DOCKER_REGISTRY || 'docker.io' }}
|
||||
REPOSITORY: "codfrm/dnspod-watch"
|
||||
GOPROXY: ${{ secrets.GOPROXY && secrets.GOPROXY || 'https://goproxy.cn,direct' }}
|
||||
RUNNER_TOOL_CACHE: /toolcache
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4.2.0
|
||||
with:
|
||||
go-version: '1.21'
|
||||
|
||||
- name: Lint
|
||||
# uses: golangci/golangci-lint-action@v3
|
||||
uses: actions/golangci-lint-action@v3
|
||||
with:
|
||||
version: latest
|
||||
install-mode: goinstall
|
||||
|
||||
- name: Tests
|
||||
run: |
|
||||
go test $(go list ./...)
|
||||
|
||||
- name: Build binary file
|
||||
run: |
|
||||
CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build -o ${{ env.APP_NAME }} ./cmd/app
|
||||
|
||||
- name: Set up QEMU
|
||||
# uses: docker/setup-qemu-action@v3
|
||||
uses: actions/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
# uses: docker/setup-buildx-action@v3
|
||||
uses: actions/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
# uses: docker/login-action@v3
|
||||
uses: actions/login-action@v1
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
|
||||
- name: Set outputs
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Docker build and push
|
||||
# use: docker/build-push-action@v5
|
||||
uses: actions/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
file: deploy/docker/Dockerfile
|
||||
tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ steps.vars.outputs.sha_short }}
|
||||
context: .
|
||||
build-args: |
|
||||
APP_NAME=${{ env.APP_NAME }}
|
||||
|
||||
- name: Set up kubeconfig
|
||||
# uses: azure/k8s-set-context@v3
|
||||
uses: actions/k8s-set-context@v3
|
||||
with:
|
||||
method: kubeconfig
|
||||
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
||||
context: k8s-context
|
||||
|
||||
- name: Set up Helm
|
||||
# uses: azure/setup-helm@v3
|
||||
uses: actions/setup-helm@v3.6
|
||||
with:
|
||||
version: 'v3.13.1' # default is latest (stable)
|
||||
|
||||
- name: Deploy
|
||||
run: |
|
||||
cd deploy/helm
|
||||
helm upgrade --install --namespace $NAMESPACE $APP_NAME . \
|
||||
--set image.tag=${{ steps.vars.outputs.sha_short }} --set image.repository=${{ env.REGISTRY }}/${{ env.REPOSITORY }} \
|
||||
--set etcdConfig.password=${{ secrets.ETCD_CONFIG_PASSWORD }}
|
Reference in New Issue
Block a user