💚 update workflow
This commit is contained in:
1 parent
953d3b4135
commit
b268d03e30
3 files changed
+21
-79
No files matched your search
@@ -1,60 +0,0 @@
|
|||||||
name: build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ dev-lwx ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ dev-lwx ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Go 1.15
|
|
||||||
uses: actions/setup-go@v1
|
|
||||||
with:
|
|
||||||
go-version: 1.15
|
|
||||||
id: go
|
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Get dependencies
|
|
||||||
run: |
|
|
||||||
go get -v -t -d ./...
|
|
||||||
if [ -f Gopkg.toml ]; then
|
|
||||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
||||||
dep ensure
|
|
||||||
fi
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin .
|
|
||||||
mv go-admin ./scripts
|
|
||||||
|
|
||||||
- uses: Azure/docker-login@v1
|
|
||||||
with:
|
|
||||||
login-server: registry.cn-shanghai.aliyuncs.com
|
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
- run: |
|
|
||||||
docker build ./scripts -t registry.cn-shanghai.aliyuncs.com/go-admin-team/go-admin:${{ github.sha }}
|
|
||||||
docker push registry.cn-shanghai.aliyuncs.com/go-admin-team/go-admin:${{ github.sha }}
|
|
||||||
- uses: Azure/k8s-set-context@v1
|
|
||||||
with:
|
|
||||||
kubeconfig: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
|
|
||||||
- uses: Azure/k8s-create-secret@v1
|
|
||||||
with:
|
|
||||||
namespace: 'go-admin'
|
|
||||||
container-registry-url: registry.cn-shanghai.aliyuncs.com
|
|
||||||
container-registry-username: ${{ secrets.REGISTRY_USERNAME }}
|
|
||||||
container-registry-password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
||||||
secret-name: aliyuncs-k8s-secret
|
|
||||||
|
|
||||||
- uses: Azure/k8s-deploy@v1
|
|
||||||
with:
|
|
||||||
namespace: 'go-admin'
|
|
||||||
manifests: 'scripts/k8s/deploy.yml'
|
|
||||||
images: 'registry.cn-shanghai.aliyuncs.com/go-admin-team/go-admin:${{ github.sha }}'
|
|
||||||
imagepullsecrets: 'aliyuncs-k8s-secret'
|
|
||||||
kubectl-version: 'latest'
|
|
||||||
+18
-16
@@ -16,29 +16,23 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.14
|
- name: Set up Go 1.15
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.14
|
go-version: 1.15
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
run: |
|
run: go mod tidy
|
||||||
go get -v -t -d ./...
|
|
||||||
if [ -f Gopkg.toml ]; then
|
|
||||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
|
||||||
dep ensure
|
|
||||||
fi
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: make build
|
||||||
ref=${{ github.ref }}
|
|
||||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin .
|
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Log in to the Container registry
|
||||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
uses: docker/login-action@v2
|
||||||
|
if: startsWith(${{github.ref}}, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
@@ -46,12 +40,20 @@ jobs:
|
|||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
if: startsWith(${{github.ref}}, 'refs/tags/')
|
||||||
|
uses: docker/metadata-action@v4
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
flavor: |
|
||||||
|
latest=auto
|
||||||
|
tags: |
|
||||||
|
type=schedule
|
||||||
|
type=ref,event=tag
|
||||||
|
type=sha,prefix=,format=long,enable=true,priority=100
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
uses: docker/build-push-action@v3
|
||||||
|
if: startsWith(${{github.ref}}, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: scripts/Dockerfile
|
file: scripts/Dockerfile
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ PROJECT:=go-admin
|
|||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 go build -o go-admin main.go
|
CGO_ENABLED=0 go build -ldflags="-w -s" -a -installsuffix -o go-admin .
|
||||||
build-linux:
|
build-linux:
|
||||||
env GOOS=linux GOARCH=amd64 go build
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -a -installsuffix -o go-admin .
|
||||||
build-sqlite:
|
build-sqlite:
|
||||||
go build -tags sqlite3 -o go-admin main.go
|
go build -tags sqlite3 -ldflags="-w -s" -a -installsuffix -o go-admin .
|
||||||
#.PHONY: test
|
#.PHONY: test
|
||||||
#test:
|
#test:
|
||||||
# go test -v ./... -cover
|
# go test -v ./... -cover
|
||||||
|
|||||||
Reference in new issue
Block a user