From 946d2629b312c4e04a392cadef312081b2851fa9 Mon Sep 17 00:00:00 2001 From: Vladimir Zagainov Date: Sat, 17 Oct 2026 18:06:48 +0300 Subject: [PATCH] Add Gitea Actions CI pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add .gitea/workflows/ci.yml with test → build → docker pipeline. Docker images pushed to gitea.mrixs.me/mrixs/ym-dl on master and v* tags. Requires PACKAGES_TOKEN repo secret (read:package, write:package). --- .gitea/workflows/ci.yml | 105 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..b04f083 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,105 @@ +name: CI/CD + +# Required repo secret: PACKAGES_TOKEN +# Generate at: Gitea → User Settings → Applications → Generate New Token +# Scopes: read:package, write:package +# Save as: Repository → Settings → Actions → Secrets → PACKAGES_TOKEN +# Note: GITHUB_TOKEN is read-only for packages in Gitea (issue #23642). + +on: + push: + branches: ["master"] + tags: ["v*"] + pull_request: + branches: ["master"] + +env: + GO_VERSION: "1.27.2" + REGISTRY: "gitea.mrixs.me" + IMAGE_NAME: "ym-dl" + # Using a fixed username since GITEA_REPOSITORY_OWNER may not be available + # Replace with your actual Gitea username (must be lowercase for Docker) + USERNAME: "mrixs" + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache Go modules + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: go-test-${{ runner.os }}-${{ hashFiles('go.sum') }} + restore-keys: | + go-test-${{ runner.os }}- + + - name: Download Go modules + run: go mod download + + - name: Run tests + run: go test ./... -v -race -cover + + build: + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Cache Go modules and build cache + uses: actions/cache@v4 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: go-build-${{ runner.os }}-${{ hashFiles('go.sum') }} + restore-keys: | + go-build-${{ runner.os }}- + + - name: Download Go modules + run: go mod download + + - name: Build binary + run: go build -o ym-dl ./cmd/ym-dl + + docker: + runs-on: ubuntu-latest + needs: build + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Gitea Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.USERNAME }} + password: ${{ secrets.PACKAGES_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:latest + ${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:buildcache + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.USERNAME }}/${{ env.IMAGE_NAME }}:buildcache,mode=max