Skip to content

Commit

Permalink
ci: build container image
Browse files Browse the repository at this point in the history
  • Loading branch information
xfoxfu committed Jul 12, 2024
1 parent 2213ac5 commit f5185d0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 8 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 1 addition & 8 deletions Net.Vatprc.Uniapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down

0 comments on commit f5185d0

Please sign in to comment.