diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index c5e8851..48ff339 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -15,19 +15,17 @@ env: IMAGE_NAME: admin/taskpool jobs: - build-and-push: - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: - - name: Install Node.js - run: | - apt-get update - apt-get install -y curl - curl -fsSL https://deb.nodesource.com/setup_22.x | bash - - apt-get install -y nodejs - node --version + build: + name: Build Frontend + runs-on: ubuntu + container: + image: node:22 + defaults: + run: + working-directory: web - - name: Checkout + steps: + - name: Checkout repository uses: actions/checkout@v4 - name: Setup pnpm @@ -35,19 +33,61 @@ jobs: with: version: 9 + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT + id: pnpm-cache + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install dependencies - working-directory: web run: pnpm install --frozen-lockfile - name: Build - working-directory: web run: pnpm build + docker: + name: Build and Push Docker Image + runs-on: ubuntu + needs: build + if: github.event_name == 'push' + env: + RUNNER_TOOL_CACHE: /toolcache + + steps: + - name: Install Docker CLI + run: | + if ! command -v docker &> /dev/null; then + if command -v apk &> /dev/null; then + apk add --no-cache docker-cli + elif command -v apt-get &> /dev/null; then + apt-get update && apt-get install -y docker.io + else + curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz | tar xz -C /tmp + mv /tmp/docker/docker /usr/local/bin/ + chmod +x /usr/local/bin/docker + fi + fi + docker --version + + - name: Checkout repository + uses: actions/checkout@v4 + - name: Login to Registry run: echo "${{ secrets.TOKEN }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin - - name: Build and push Docker image + - name: Build Docker image run: | docker build -f Dockerfile.standalone -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} . + + - name: Push Docker image + run: | docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}