feat: add tmp ci file

This commit is contained in:
sangge 2024-01-06 03:08:15 +08:00
parent 3653ea8b32
commit 1d58964f7d

View File

@ -0,0 +1,84 @@
name: Go CI/CD
on:
push:
branches:
- dev
env:
PACKAGE_VERSION: "1.3.3"
LINUX_AMD64_BINARY: "console-${{ env.PACKAGE_VERSION }}"
PACKAGE_REGISTRY_URL: "${{ secrets.CI_API_V4_URL }}/projects/${{ github.repository }}/${{ env.PACKAGE_VERSION }}"
CI_COMMIT_TAG: "1.3.3"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19.8 # Use the Go version you require
- name: Build binary
run: |
go build -o ${{ env.LINUX_AMD64_BINARY }} console.go
echo ${{ env.PACKAGE_VERSION }} > version.txt
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: console
path: ${{ env.LINUX_AMD64_BINARY }}
docker_build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Login to Docker Registry
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin reg.sre.victor-core.top
- name: Build Docker image
run: |
docker build -t console:${{ env.PACKAGE_VERSION }} .
docker tag console:${{ env.PACKAGE_VERSION }} reg.sre.victor-core.top/cobalt-strike/console:${{ env.PACKAGE_VERSION }}
working-directory: ${{ github.workspace }}
- name: Push Docker image
run: docker push reg.sre.victor-core.top/cobalt-strike/console:${{ env.PACKAGE_VERSION }}
release:
runs-on: ubuntu-latest
steps:
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.LINUX_AMD64_BINARY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
shell: bash
- name: Apply Kubernetes Deployment
run: kubectl apply -f deployment.yaml --kubeconfig=.kube/config --certificate-authority=.kube/ca.pem
working-directory: ${{ github.workspace }}