build-and-deploy-web #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-deploy-web | |
on: workflow_dispatch | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
name: Build images | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v4 | |
- name: Restore cached npm dependencies | |
id: cache-npm-deps | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
node_modules | |
~/.cache/Cypress # needed for the Cypress binary | |
key: npm-dependencies-${{ hashFiles('package.json') }} | |
- name: Install dependencies | |
run: pnpm install | |
if: steps.cache-npm-deps.outputs.cache-hit != 'true' | |
- name: Cache npm dependencies | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
node_modules | |
~/.cache/Cypress # needed for the Cypress binary | |
key: npm-dependencies-${{ hashFiles('package.json') }} | |
# - name: Pull existing base image | |
# run: docker pull registry.digitalocean.com/linkerry/base:latest || echo "No existing image to pull" | |
- name: Build base image | |
run: npm run docker-base-linux | |
# - name: Tag base image | |
# run: docker tag linkerry/base registry.digitalocean.com/linkerry/base:latest | |
- name: Install doctl | |
uses: digitalocean/action-doctl@v2 | |
with: | |
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | |
- name: Log in to DO Container Registry | |
run: doctl registry login --expiry-seconds 1000 | |
- name: Push image to DO Container Registry | |
run: docker push registry.digitalocean.com/linkerry/base:latest | |
- name: Build image for web | |
env: | |
NEXT_TELEMETRY_DISABLED: true | |
NEXT_PUBLIC_API_HOST: https://api.linkerry.com | |
run: docker build -t linkerry/web --build-arg NEXT_PUBLIC_API_HOST=$NEXT_PUBLIC_API_HOST -f ./apps/web/Dockerfile . --platform=linux/amd64 | |
- name: Tag web image | |
run: docker tag linkerry/web registry.digitalocean.com/linkerry/web:latest | |
- name: Push image to DO Container Registry | |
run: docker push registry.digitalocean.com/linkerry/web:latest |