0
v-firecrawl/.gitea/workflows/main.yml

70 lines
2.4 KiB
YAML
Raw Normal View History

name: Build and Push Docker Image
on:
push:
branches:
- "main"
- "dev"
release:
types: [published]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
2024-06-19 03:41:03 -04:00
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install pnpm
run: npm install -g pnpm
- name: Download dependencies to cache
run: |
mkdir -p /opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/pnpm/
pnpm fetch --prod --lockfile-only --lockfile-path=apps/api/pnpm-lock.yaml --store-dir /opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/pnpm/
mkdir -p ${{ gitea.workspace }}/cache
cp -r /opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/pnpm/* ${{ gitea.workspace }}/cache/
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
uses: docker/metadata-action@v5
id: meta
with:
images: vontainment/v-gpt-node-app
flavor: latest=false
tags: |
type=raw,value=main,enable=${{ gitea.ref == 'refs/heads/main' }}
type=raw,value=dev,enable=${{ gitea.ref == 'refs/heads/dev' }}
type=sha,priority=100,enable=${{ gitea.event_name == 'push' }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: apps/api/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PNPM_CACHE=${{ gitea.workspace }}/cache
cache-from: type=local,src=/opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/build/
cache-to: type=local,dest=/opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/build-new/
- name: Rotate build cache
run: |
rm -rf /opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/build/
mv /opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/build-new/ /opt/hostedtoolcache/${{ gitea.repository }}-${{ gitea.ref_name }}/build/