Skip to content

Commit

Permalink
ci(actions): pull base image to speedup build, fix package deps cache
Browse files Browse the repository at this point in the history
  • Loading branch information
anteqkois committed May 19, 2024
1 parent c78ae7f commit f39312a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy-api-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: doctl registry login --expiry-seconds 600
- name: Push image to DO Container Registry
run: docker push registry.digitalocean.com/linkerry/base:latest
- name: Build image for web
- name: Build image for api-gateway
env:
NEXT_TELEMETRY_DISABLED: true
NEXT_PUBLIC_API_HOST: https://api.linkerry.com
Expand Down
27 changes: 14 additions & 13 deletions .github/workflows/build-and-deploy-web.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: build-and-deploy-web

on:
workflow_dispatch
on: workflow_dispatch

jobs:
build_and_deploy:
Expand All @@ -12,9 +11,8 @@ jobs:
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
# with:
# version: 8
- name: Restore cached npm dependencies
id: cache-npm-deps
uses: actions/cache/restore@v4
with:
path: |
Expand All @@ -23,31 +21,34 @@ jobs:
key: npm-dependencies-${{ hashFiles('package.json') }}
- name: Install dependencies
run: pnpm install
if: steps.cache.outputs.cache-hit != 'true'
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: 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 600
- 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: Push image to DO Container Registry
run: docker push registry.digitalocean.com/linkerry/base:latest
- name: Build image for web
run: docker build -t linkerry/web -f ./apps/web/Dockerfile . --platform=linux/amd64
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
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
1 change: 1 addition & 0 deletions docs/git/pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Insted `gut pull`, prefer `git pull --rebase`, it produce better git history. When there is a conflict, then use base `git pull`

0 comments on commit f39312a

Please sign in to comment.