Files
static-pages/.github/workflows/build.yml
T
renovate[bot] 3b92e849ee chore(deps): update github-actions (#322)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-01-13 14:44:55 -05:00

198 lines
6.8 KiB
YAML

name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
tofu_version: '1.10.2'
tg_version: '0.83.0'
ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'prod' || 'dev' }}
jobs:
build-frontend:
name: Build Frontend
runs-on: ubuntu-latest
strategy:
matrix:
app_name: ['root', 'api', 'awesome', 'my', 'get', 'buy', 'datasets']
defaults:
run:
working-directory: apps/${{ matrix.app_name }}.immich.app
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup Node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version-file: './.nvmrc'
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- name: Install
run: pnpm install
- name: Build
env:
PUBLIC_IMMICH_PAY_HOST: ${{ env.ENVIRONMENT == 'dev' && 'https://futopay-test.azurewebsites.net' || 'https://pay.futo.org' }}
PUBLIC_CF_TURNSTILE_SITE: ${{ secrets.CF_TURNSTILE_DEFAULT_INVISIBLE_SITE_KEY }}
run: pnpm build
- name: Upload build output
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: build-frontend-output-${{ matrix.app_name }}
include-hidden-files: true
path: apps/${{ matrix.app_name }}.immich.app/build
retention-days: 1
build-backend:
name: Build Backend
runs-on: ubuntu-latest
strategy:
matrix:
app_name: ['datasets']
defaults:
run:
working-directory: apps/${{ matrix.app_name }}.immich.app/backend
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- name: Setup Node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version-file: './.nvmrc'
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- name: Run pnpm install
run: pnpm install
- name: Build backend
run: npx wrangler build
- name: Upload build output
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: build-backend-output-${{ matrix.app_name }}
path: 'apps/${{ matrix.app_name }}.immich.app/backend/dist'
retention-days: 1
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: [build-frontend, build-backend]
strategy:
fail-fast: false
matrix:
app_name: ['root', 'api', 'awesome', 'my', 'get', 'buy', 'datasets']
env:
TF_VAR_app_name: ${{ matrix.app_name }}
TF_VAR_stage: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
TF_VAR_dist_dir: ${{github.workspace}}/dist/backend
OP_SERVICE_ACCOUNT_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.OP_TF_PROD_ENV || secrets.OP_TF_DEV_ENV }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Get build artifact
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: 'build-frontend-output-${{ matrix.app_name }}'
path: '${{ github.workspace }}/dist/frontend'
- name: Check if the app has a backend folder
id: check-backend
run: |
if [ -d "apps/${{ matrix.app_name }}.immich.app/backend" ]; then
echo "has_backend=true" >> $GITHUB_ENV
else
echo "has_backend=false" >> $GITHUB_ENV
fi
- name: Get backend build artifact
if: ${{ env.has_backend == 'true' }}
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
name: 'build-backend-output-${{ matrix.app_name }}'
path: '${{ github.workspace }}/dist/backend'
- name: Install 1Password CLI
uses: 1password/install-cli-action@9a0c9dd934086b7ab1d90115d455bda1c53c2bdb # v2
- name: Install Terragrunt
uses: eLco/setup-terragrunt@2c5116f8979bb261072ef57c97ac026cd9c27434 # v1
with:
terragrunt_version: ${{ env.tg_version }}
- name: 'Install OpenTofu'
uses: opentofu/setup-opentofu@e95ccdd20623115bfd7d47df14a3250d6066a9d0 # v1
with:
tofu_version: ${{ env.tofu_version }}
tofu_wrapper: false
- name: Deploy All
working-directory: ${{ github.workspace }}/deployment
run: |
INCLUDE_DIRS=""
if [ "${{ env.has_backend }}" = "true" ]; then
INCLUDE_DIRS='**/workers/${{ matrix.app_name }}'
fi
op run --env-file='.env' -- terragrunt run --all apply \
--non-interactive \
--parallelism 1 \
--queue-include-dir='**/!(workers)/**' \
--queue-include-dir="$INCLUDE_DIRS"
- name: Cloudflare Deploy Output
id: deploy-output
working-directory: ${{ github.workspace }}/deployment/modules/cloudflare/static-pages
run: |
echo "output=$(op run --no-masking --env-file='../../../.env' -- terragrunt output -json | jq -c .)" >> $GITHUB_OUTPUT
- name: Publish Frontend to Cloudflare Pages
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca # v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN_PAGES_UPLOAD }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ fromJson(steps.deploy-output.outputs.output).pages_project_name.value }}
directory: 'dist/frontend'
branch: ${{ fromJson(steps.deploy-output.outputs.output).pages_branch.value }}
wranglerVersion: '3'
- name: Comment
uses: actions-cool/maintain-one-comment@4b2dbf086015f892dcb5e8c1106f5fccd6c1476b # v3
if: ${{ github.event_name == 'pull_request' }}
with:
number: ${{ github.event.number }}
body: |
📖 Preview of ${{ matrix.app_name }}.immich.app deployed to [${{ fromJson(steps.deploy-output.outputs.output).immich_subdomain.value }}](https://${{ fromJson(steps.deploy-output.outputs.output).immich_subdomain.value }})
emojis: 'rocket'
body-include: '<!-- ${{ matrix.app_name }} PR URL -->'