From 1d58964f7d999103ef0caab6b07055589a4d17e9 Mon Sep 17 00:00:00 2001 From: sangge <2251250136@qq.com> Date: Sat, 6 Jan 2024 03:08:15 +0800 Subject: [PATCH] feat: add tmp ci file --- .gitea/workflows/deploy.yaml | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .gitea/workflows/deploy.yaml diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..36bf2e3 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -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 }}