mirror of
https://github.com/immich-app/data.immich.app.git
synced 2026-09-30 13:23:26 +08:00
chore(deps): update github-actions Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
134 lines
4.6 KiB
YAML
134 lines
4.6 KiB
YAML
name: Build and Deploy
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
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:
|
|
strategy:
|
|
matrix:
|
|
name: [backend, frontend]
|
|
name: Build ${{ matrix.name }}
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./${{ matrix.name }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
|
|
with:
|
|
node-version-file: './${{ matrix.name }}/.nvmrc'
|
|
|
|
- name: Run npm install
|
|
run: npm ci
|
|
|
|
- name: Run build
|
|
run: npm run build
|
|
|
|
- name: Upload build output
|
|
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: build-output-${{ matrix.name }}
|
|
if-no-files-found: error
|
|
path: dist
|
|
retention-days: 1
|
|
|
|
merge:
|
|
name: Merge Artifacts
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Merge Artifacts
|
|
uses: actions/upload-artifact/merge@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
|
|
with:
|
|
name: build-output
|
|
retention-days: 1
|
|
|
|
deploy:
|
|
name: Deploy
|
|
runs-on: ubuntu-latest
|
|
needs: merge
|
|
env:
|
|
TF_VAR_dist_dir: ${{ github.workspace }}/dist
|
|
TF_VAR_stage: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || '' }}
|
|
TF_VAR_pages_branch: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name }}
|
|
OP_SERVICE_ACCOUNT_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.OP_TF_PROD_ENV || secrets.OP_TF_DEV_ENV }}
|
|
working_dir: 'deployment'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
|
|
|
|
- name: 'Get build artifact'
|
|
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
|
|
with:
|
|
name: build-output
|
|
path: '${{ github.workspace }}/dist'
|
|
|
|
- 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@000eeb8522f0572907c393e8151076c205fdba1b # v1
|
|
with:
|
|
tofu_version: ${{ env.tofu_version }}
|
|
tofu_wrapper: false
|
|
|
|
- name: Deploy All
|
|
working-directory: ${{ env.working_dir }}
|
|
run: op run --env-file=".env" -- terragrunt run --all apply --non-interactive
|
|
|
|
- name: Deploy Backend Output
|
|
id: deploy-backend-output
|
|
working-directory: ${{ env.working_dir }}/modules/cloudflare/backend
|
|
run: |
|
|
echo "output=$(op run --no-masking --env-file='../../../.env' -- terragrunt output -json | jq -c .)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Deploy Frontend Output
|
|
id: deploy-frontend-output
|
|
working-directory: ${{ env.working_dir }}/modules/cloudflare/frontend
|
|
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-frontend-output.outputs.output).pages_project_name.value }}
|
|
directory: 'dist/frontend'
|
|
branch: ${{ fromJson(steps.deploy-frontend-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 deployed to:
|
|
- Frontend URL: https://${{ fromJson(steps.deploy-frontend-output.outputs.output).immich_subdomain.value }}
|
|
- Backend URL: ${{ fromJson(steps.deploy-backend-output.outputs.output).data_api_url.value }}
|
|
emojis: 'rocket'
|
|
body-include: '<!-- web PR URL -->'
|