114 lines
3.4 KiB
YAML
114 lines
3.4 KiB
YAML
name: Build and Test - Production
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
repo_name: ${{ steps.project_metadata.outputs.REPO_NAME }}
|
|
repo_version_hash: ${{ steps.project_metadata.outputs.REPO_VERSION_HASH }}
|
|
project_version: ${{ steps.project_metadata.outputs.PROJECT_VERSION }}
|
|
steps:
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node Environment
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: ">=22.20"
|
|
|
|
- name: Setup Project Dependencies
|
|
run: |
|
|
npm ci
|
|
npx playwright install --with-deps
|
|
|
|
- name: Code Formatting Check
|
|
run: npx prettier . --check
|
|
|
|
- name: Spelling Check
|
|
run: npx cspell .
|
|
|
|
- name: Build Project
|
|
run: npm run build
|
|
|
|
- name: Run Unit Tests
|
|
run: npm run test
|
|
|
|
- name: Run E2E Tests
|
|
run: npm run e2e-test
|
|
|
|
- name: Set Project Metadata
|
|
id: project_metadata
|
|
run: |
|
|
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
|
|
echo REPO_VERSION_HASH=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT
|
|
|
|
build_and_push:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- name: Checkout caperren-com Repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
path: caperren-com
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: 192.168.1.36:30008
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.ACTIONS_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
with:
|
|
buildkitd-config-inline: |
|
|
[registry."192.168.1.36:30008"]
|
|
http = true
|
|
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: caperren-com
|
|
push: true
|
|
tags: |
|
|
192.168.1.36:30008/caperren/${{ needs.test.outputs.repo_name }}:${{ needs.test.outputs.repo_version_hash }}
|
|
192.168.1.36:30008/caperren/caperren-com:latest
|
|
build-args: |
|
|
REPO_VERSION_HASH=${{ needs.test.outputs.repo_version_hash }}
|
|
BUILD_ENVIRONMENT=production
|
|
|
|
deploy_production:
|
|
runs-on: ubuntu-latest
|
|
needs: test
|
|
steps:
|
|
- name: Pull New Image For App
|
|
run: |
|
|
curl -k -X 'POST' \
|
|
'https://caperren.com:444/api/v2.0/app/pull_images' \
|
|
-H 'accept: */*' \
|
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{
|
|
"name": "caperren-com",
|
|
"options": {}
|
|
}'
|
|
- name: Stop App
|
|
run: |
|
|
curl -k -X 'POST' \
|
|
'https://caperren.com:444/api/v2.0/app/stop' \
|
|
-H 'accept: */*' \
|
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
|
-H 'Content-Type: application/json' \
|
|
-d '"caperren-com"'
|
|
- name: Start App
|
|
run: |
|
|
curl -k -X 'POST' \
|
|
'https://caperren.com:444/api/v2.0/app/start' \
|
|
-H 'accept: */*' \
|
|
-H 'Authorization: Bearer ${{ secrets.TRUENAS_CAPERRENCOM_API_KEY }}' \
|
|
-H 'Content-Type: application/json' \
|
|
-d '"caperren-com"'
|