Skip to content

Commit

Permalink
ci(npcs): update
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaosen7 committed Jul 30, 2024
1 parent 55f8dfb commit 21b9c04
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-large-file-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Call Docker Build Action
uses: ./.github/actions/docker-build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Call Docker Build Action
uses: ./.github/actions/docker-build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-stackoverflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Call Docker Build Action
uses: ./.github/actions/docker-build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Call Docker Build Action
uses: ./.github/actions/docker-build
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ name: Docker Build

on:
push:
paths:
- "apps/**"
- ".github/workflows/docker-build.yml"
branches:
- "**"

jobs:
generate-matrix:
Expand Down Expand Up @@ -41,7 +40,7 @@ jobs:
- name: Login Registry
if: github.ref == 'refs/heads/main'
run: |
echo ${{ secrets.PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
echo ${{ secrets.PAT }} | docker login ${{ secrets.REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Build Docker Image
id: docker_build
Expand All @@ -63,3 +62,12 @@ jobs:
echo "Docker Image ID: ${{ steps.docker_build.outputs.imageid }}"
echo "Docker Image digest: ${{ steps.docker_build.outputs.digest }}"
echo "Docker Image metadata: ${{ steps.docker_build.outputs.metadata }}"
- name: Trigger Deploy
if: github.ref == 'refs/heads/main'
run: |
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
https://api.github.com/repos/${{ github.repository }}/dispatches \
-d '{"event_type":"deploy"}'
38 changes: 38 additions & 0 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# .github/workflows/docker-deploy.yml
name: Docker Deploy

on:
repository_dispatch:
types: [deploy]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Upload to VPS
uses: appleboy/scp-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
source: ./deploy
target: ${{ secrets.VPS_WORK_DIR }}

- name: Execute deployment via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
port: ${{ secrets.VPS_PORT }}
envs: REPO_NAME
script: |
cd ${{ secrets.VPS_WORK_DIR }}/deploy
docker compose pull
docker compose up -d
docker image prune -f

0 comments on commit 21b9c04

Please sign in to comment.