From efc62c01f1035520be2337a312109d27d9d4a776 Mon Sep 17 00:00:00 2001 From: ptruessel Date: Fri, 6 Dec 2024 12:02:08 +0100 Subject: [PATCH 1/2] Added exclude in github action --- .github/workflows/deploy-production.yml | 2 +- .github/workflows/deploy-staging.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index a976b6d..8c8ac65 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -16,7 +16,7 @@ jobs: - name: Deploy to server via rsync uses: Burnett01/rsync-deployments@5.2 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 }} diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index 8081390..f1152c7 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -16,7 +16,7 @@ jobs: - name: Deploy to server via rsync uses: Burnett01/rsync-deployments@5.2 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 }} From fd5e54cac28fd9f4198207d8a3034e4e2022eb58 Mon Sep 17 00:00:00 2001 From: ptruessel Date: Fri, 6 Dec 2024 15:21:48 +0100 Subject: [PATCH 2/2] Added css and js minifying in github action yml --- .github/workflows/deploy-production.yml | 41 ++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index 8c8ac65..2d70d86 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -24,6 +24,44 @@ jobs: remote_key: ${{ secrets.PROD_KEY }} remote_key_pass: ${{ secrets.PROD_KEY_PASS }} + - name: Generate version and minify on server + uses: appleboy/ssh-action@v1.0.3 + 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/ssh-action@v1.0.3 + 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/ssh-action@v1.0.3 with: @@ -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 \ No newline at end of file + flyway/flyway -locations=filesystem:/flyway/myapp -table=flyway_myapp migrate +