Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging to Production #575

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,52 @@ jobs:
- name: Deploy to server via rsync
uses: Burnett01/[email protected]
with:
switches: -avzr --delete --exclude-from='.gitignore' --exclude='/config/nginx/conf.d/custom.conf'
switches: -avzr --checksum --delete --exclude-from='.gitignore' --exclude='/config/nginx/conf.d/custom.conf'
path: ./
remote_path: ${{ secrets.PROD_REMOTE_PATH }}
remote_host: ${{ secrets.PROD_HOST }}
remote_user: ${{ secrets.PROD_USER }}
remote_key: ${{ secrets.PROD_KEY }}
remote_key_pass: ${{ secrets.PROD_KEY_PASS }}

- name: Generate version and minify on server
uses: appleboy/[email protected]
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_KEY }}
passphrase: ${{ secrets.PROD_KEY_PASS }}
script: |
TIMESTAMP=$(date +%Y%m%d%H%M)
echo "{\"version\":\"$TIMESTAMP\"}" > ${{ secrets.PROD_REMOTE_PATH }}/www/frontend/custom_theme/css/version.json
echo "{\"version\":\"$TIMESTAMP\"}" > ${{ secrets.PROD_REMOTE_PATH }}/www/frontend/custom_theme/js/version.json

docker run --rm \
-v ${{ secrets.PROD_REMOTE_PATH }}/www:/www \
node:18 sh -c "npm install -g csso-cli && \
csso /www/frontend/custom_theme/css/styles.css --output /www/frontend/custom_theme/css/styles.min.css"

docker run --rm \
-v ${{ secrets.PROD_REMOTE_PATH }}/www:/www \
node:18 sh -c "npm install -g terser && \
terser /www/frontend/custom_theme/js/scripts.js --compress --mangle --output /www/frontend/custom_theme/js/scripts.min.js"

- name: Run Flyway Migrations core
uses: appleboy/[email protected]
with:
host: ${{ secrets.PROD_HOST }}
username: ${{ secrets.PROD_USER }}
key: ${{ secrets.PROD_KEY }}
passphrase: ${{ secrets.PROD_KEY_PASS }}
script: |
docker run --rm \
--network npm_network \
--volume ${{ secrets.PROD_REMOTE_PATH }}/config/db/core:/flyway/core:ro \
-e FLYWAY_URL="${{ secrets.PROD_DB_URL }}" \
-e FLYWAY_USER="${{ secrets.PROD_DB_USER }}" \
-e FLYWAY_PASSWORD="${{ secrets.PROD_DB_PASSWORD }}" \
flyway/flyway -locations=filesystem:/flyway/core -table=flyway_core migrate

- name: Run Flyway Migrations core
uses: appleboy/[email protected]
with:
Expand Down Expand Up @@ -54,4 +92,5 @@ jobs:
-e FLYWAY_URL="${{ secrets.PROD_DB_URL }}" \
-e FLYWAY_USER="${{ secrets.PROD_DB_USER }}" \
-e FLYWAY_PASSWORD="${{ secrets.PROD_DB_PASSWORD }}" \
flyway/flyway -locations=filesystem:/flyway/myapp -table=flyway_myapp migrate
flyway/flyway -locations=filesystem:/flyway/myapp -table=flyway_myapp migrate

2 changes: 1 addition & 1 deletion .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Deploy to server via rsync
uses: Burnett01/[email protected]
with:
switches: -avzr --delete --exclude-from='.gitignore' --exclude='/config/nginx/conf.d/custom.conf'
switches: -avzr --checksum --delete --exclude-from='.gitignore' --exclude='/config/nginx/conf.d/custom.conf'
path: ./
remote_path: ${{ secrets.STAGING_REMOTE_PATH }}
remote_host: ${{ secrets.STAGING_HOST }}
Expand Down