Skip to content

Commit

Permalink
No longer auto deploy to prod on push (#960) [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
sceuick authored Jul 1, 2024
1 parent 69c938a commit 8d679ac
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

# ssh ci@$@ "docker stack deploy -c /home/ci/agn.docker-compose.yml agnaistic"
ssh ci@$@ "sh deploy-prd.sh"
4 changes: 0 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,3 @@ jobs:
run: |
docker push ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:latest
docker push ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITHUB_SHA
- name: Update Service
run: |
sh .github/deploy.sh ${{ secrets.SSH_SERVER }}
17 changes: 0 additions & 17 deletions .github/workflows/dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,3 @@ jobs:
aws_bucket: ${{ secrets.S3_DEV_ASSET_BUCKET }}
source_dir: 'dist'
destination_dir: ''

# - name: Build image
# run: |
# docker build -f Dockerfile -t ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:dev --build-arg SHA=$GITHUB_SHA .
# docker tag ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:dev ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITHUB_SHA

# - name: Log in to Container Registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

# - name: Publish
# run: |
# docker push ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:dev
# docker push ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$GITHUB_SHA

# - name: Update Service
# run: |
# sh .github/dev-deploy.sh ${{ secrets.SSH_SERVER }}
64 changes: 64 additions & 0 deletions .github/workflows/prd-deploy-stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy to PRD (Web + API)

on: workflow_dispatch

env:
IMAGE_NAME: agnaistic
node-version: '18.4.0'
pnpm-version: 8.6.0

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get cached dependencies
# cache is automatically saved after this job completes. jobs depending on this one will get the latest cached files
id: cache-step
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: 'none'

- name: Add known host
run: |
ssh-keyscan -H ${{ secrets.SSH_SERVER }} >> ~/.ssh/known_hosts
- name: Install project dependencies
if: steps.cache-step.outputs.cache-hit != 'true'
run: |
ls -la
echo $NODE_ENV
pnpm install --frozen-lockfile
- name: Build frontend
env:
INJECT_SCRIPT: ${{ secrets.INJECT_SCRIPT }}
run: |
pnpm run build:prod
cp dist/index.html dist/original.html
node .github/inject.js
- name: Update Backend
run: |
sh .github/deploy.sh ${{ secrets.SSH_SERVER }}
- name: Update Frontend
uses: shallwefootball/s3-upload-action@master
with:
aws_key_id: ${{ secrets.S3_ASSET_ACCESS_KEY }}
aws_secret_access_key: ${{ secrets.S3_ASSET_SECRET_KEY }}
aws_bucket: ${{ secrets.S3_PRD_ASSET_BUCKET }}
source_dir: 'dist'
destination_dir: ''
4 changes: 2 additions & 2 deletions .github/workflows/web-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Web deploy
name: Web deploy (to DEV)

on:
push:
Expand Down Expand Up @@ -51,6 +51,6 @@ jobs:
with:
aws_key_id: ${{ secrets.S3_ASSET_ACCESS_KEY }}
aws_secret_access_key: ${{ secrets.S3_ASSET_SECRET_KEY }}
aws_bucket: ${{ secrets.S3_PRD_ASSET_BUCKET }}
aws_bucket: ${{ secrets.S3_DEV_ASSET_BUCKET }}
source_dir: 'dist'
destination_dir: ''

0 comments on commit 8d679ac

Please sign in to comment.