Deployment #38
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: Deployment | |
on: | |
workflow_run: | |
workflows: ["Playwright Tests"] | |
types: | |
- completed | |
jobs: | |
build: | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'master' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Install, test, deploy | |
run: | | |
pnpm install | |
pnpm test | |
pnpm build | |
env: | |
CAPROVER_PASSWORD: ${{ secrets.CAPROVER_PASSWORD }} | |
CAPROVER_MACHINE_01: ${{ secrets.CAPROVER_MACHINE_01 }} | |
CAPROVER_MACHINE_02: ${{ secrets.CAPROVER_MACHINE_02 }} | |
CI: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Preset Image Name | |
run: echo "IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(echo ${{ github.sha }} | cut -c1-7) | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Build and push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_URL }} | |
- name: Deploy Image to CapRrover | |
uses: caprover/[email protected] | |
with: | |
server: "${{ secrets.CAPROVER_MACHINE_01 }}" | |
app: "next-simple-chatgpt" | |
token: "${{ secrets.CAPROVER_APP_TOKEN_01 }}" | |
image: ${{ env.IMAGE_URL }} | |
- name: Deploy Image to CapRrover | |
uses: caprover/[email protected] | |
with: | |
server: "${{ secrets.CAPROVER_MACHINE_02 }}" | |
app: "next-simple-chatgpt" | |
token: "${{ secrets.CAPROVER_APP_TOKEN_02 }}" | |
image: ${{ env.IMAGE_URL }} |