Skip to content

Commit

Permalink
CI without Docker (#102)
Browse files Browse the repository at this point in the history
* temp: build

* test

* fix dir

* revert test changes
  • Loading branch information
dittos authored Sep 16, 2022
1 parent 1cbe265 commit 4dbf464
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 34 deletions.
54 changes: 39 additions & 15 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,42 @@ jobs:
contents: read

steps:
- uses: actions/checkout@v2
- run: docker build -t animeta-frontend .

# Build
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- run: pnpm -C frontend-server run build:bundle
- run: pnpm -C frontend run build-assets
- run: pnpm -C frontend run build-server

# Deploy
- name: Set up gcloud
Expand All @@ -33,25 +67,15 @@ jobs:
version: '270.0.0'
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
- name: Extract assets
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
mkdir /tmp/extract-static
docker run -v /tmp/extract-static:/workspace --entrypoint /bin/bash animeta-frontend -c "cp -r /app/frontend/dist/static /workspace/"
- name: Upload assets
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: gsutil -m cp -z js,css,map -r /tmp/extract-static/static gs://animeta-static/
- name: Docker push
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
gcloud auth configure-docker
docker tag animeta-frontend gcr.io/ditto-1470749749381/animeta-frontend:latest
docker push gcr.io/ditto-1470749749381/animeta-frontend:latest
run: gsutil -m cp -z js,css,map -r frontend/dist/static gs://animeta-static/
- name: Configure AWS Credentials
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ap-northeast-2
role-to-assume: arn:aws:iam::307761743095:role/animeta-deploy-github-actions-Role-19IZBY3F8TXQ
- name: Deploy lambda
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: ./deploy/lambda/build.sh && ./deploy/lambda/deploy.sh
run: ./deploy/lambda/package.sh && ./deploy/lambda/deploy.sh
1 change: 0 additions & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ COPY frontend/package.json /app/frontend/
RUN pnpm install --frozen-lockfile

COPY . .
RUN pnpm -C frontend-server run build
RUN pnpm -C frontend-server run build:bundle
RUN pnpm -C frontend run build-assets
RUN pnpm -C frontend run build-server
Expand Down
18 changes: 0 additions & 18 deletions web/deploy/lambda/build.sh

This file was deleted.

13 changes: 13 additions & 0 deletions web/deploy/lambda/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

rm -rf deploy/lambda/dist
mkdir -p deploy/lambda/dist/app/{frontend-server,frontend}

cp -r frontend-server/dist deploy/lambda/dist/app/frontend-server/
cp -r frontend/dist deploy/lambda/dist/app/frontend/

echo ANIMETA_FRONTEND_DIST_PATH=app/frontend/dist >> deploy/lambda/dist/.env

cd deploy/lambda/dist
zip --symlinks -r package.zip app .env

0 comments on commit 4dbf464

Please sign in to comment.