diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..b5d9c4f --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,69 @@ +name: Container + +on: + push: + tags: ["v*"] +jobs: + container: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Docker setup Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker metadata action + uses: docker/metadata-action@v5 + id: meta + with: + images: | + ghcr.io/${{ github.repository }} + tags: | + latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=ref,event=branch + type=semver,pattern={{raw}} + type=sha,enable=true,priority=100,prefix=commit-,suffix=,format=short + + - name: Publish images + uses: docker/build-push-action@v5 + with: + context: Net.Vatprc.Uniapi + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + + deploy: + if: github.ref_type == 'tag' + runs-on: ubuntu-latest + needs: [container] + env: + RELEASE_VERSION: ${{ github.ref_name }} + steps: + - uses: actions/checkout@v4 + with: + repository: "xfoxfu/infra" + token: ${{ secrets.GH_TOKEN_INFRA }} + - name: Install jq and moreutils (sponge) + run: | + sudo apt-get update + sudo apt-get install jq moreutils + - run: | + jq '.["uniapi"]="${{ github.ref_name }}"' release.json | sponge release.json + - name: Push update + run: | + git config --global user.email gitops@vatprc.net + git config --global user.name 'VATPRC GitOps' + git add . + git commit --message 'feat: upgrade uniapi to ${{ github.ref_name }}' + git push -u origin HEAD:main diff --git a/Net.Vatprc.Uniapi/Dockerfile b/Net.Vatprc.Uniapi/Dockerfile index c19656b..6f1212f 100644 --- a/Net.Vatprc.Uniapi/Dockerfile +++ b/Net.Vatprc.Uniapi/Dockerfile @@ -3,14 +3,7 @@ FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG TARGETARCH RUN apt update && \ - apt install -y ca-certificates curl gnupg2 && \ - mkdir -p /etc/apt/keyrings && \ - curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ - | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \ - echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" \ - | tee /etc/apt/sources.list.d/nodesource.list && \ - apt install -y build-essential nodejs npm && \ - npm install -g pnpm + apt install -y ca-certificates curl gnupg2 COPY "Net.Vatprc.Uniapi.csproj" "/src/" COPY "packages.lock.json" "/src/"