name: CI on: [push, pull_request] env: BINARY_Name: "study_xxqg" COMMIT_ID: "${{ github.sha }}" PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request." LD_FLAGS: "-w -s" HTTP_PROXY: "http://172.17.0.1:7890" HTTPS_PROXY: "http://172.17.0.1:7890" GOPROXY: "https://goproxy.cn,direct" jobs: build: name: Build binary CI runs-on: ubuntu-latest container: image: ghcr.io/catthehacker/ubuntu:act-latest # 持久化工具目录 steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - name: setup go uses: actions/setup-go@v4 with: go-version: '1.20' - name: Fetch all tags run: git fetch --force --tags - name: Check snapshot if: "!startsWith(github.ref, 'refs/tags/')" id: snapshot run: echo '::set-output name=ARG::--snapshot' - name: push release if: "startsWith(github.ref, 'refs/tags/')" id: push release uses: https://huoxue.link:12300/huoxue1/goreleaser-action@master with: version: latest args: release --timeout 5h30m --rm-dist env: GITEA_TOKEN: ${{ secrets.TOKEN }} - name: Run GoReleaser if: "!startsWith(github.ref, 'refs/tags/')" uses: https://huoxue.link:12300/huoxue1/goreleaser-action@master with: version: latest args: build --timeout 5h30m --rm-dist ${{ steps.snapshot.outputs.ARG }} env: GITEA_TOKEN: ${{ secrets.TOKEN }} - name: Set up QEMU id: qemu uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 - name: Docker meta id: meta uses: docker/metadata-action@v4 with: images: huoxue.link:12300/huoxue1/study_xxqg tags: | type=raw,value=latest type=ref,event=tag - name: Docker Login if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: registry: huoxue.link:12300 username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} - name: Build and push id: docker_build uses: docker/build-push-action@v3 with: context: . push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max shm-size: 2g ulimit: core=0:0