From c681c8eba09a0f0fd1aef8f37a599ffb2a853b2d Mon Sep 17 00:00:00 2001 From: Jordan Welch Date: Sun, 13 Oct 2024 20:25:25 -0500 Subject: [PATCH 1/4] WIP --- .github/workflows/deploy-gcp.yml | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/deploy-gcp.yml diff --git a/.github/workflows/deploy-gcp.yml b/.github/workflows/deploy-gcp.yml new file mode 100644 index 0000000..9b91cc9 --- /dev/null +++ b/.github/workflows/deploy-gcp.yml @@ -0,0 +1,62 @@ +name: Build and Deploy +# on: +# push: +# branches: +# - main +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: prod-deploy + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + environment: production + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: none + + - name: Install dependencies + uses: ramsey/composer-install@v2 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: '18.13.0' + cache: 'yarn' + + - name: Install npm dependencies + run: yarn install + + - name: Build assets + run: yarn run build + + - name: Zip up the application + run: zip -r application.zip . -x "*.git*" -x "*.github*" + + - name: Upload Application Artifact + uses: actions/upload-artifact@v4 + with: + name: application + path: application.zip + + - name: Place SSH Key + run: echo "${{ secrets.SERVER_SSH_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa + + - name: Transfer Zip to Server + run: | + TIMESTAMP=$(date +'%Y%m%d%H%M%S') + SERVER="${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}" + scp application.zip $SERVER:/tmp/application.zip + ssh $SERVER "unzip /tmp/application.zip -d /var/www/choremanager/releases/$TIMESTAMP" + ssh $SERVER "ln -sf /var/www/choremanager/releases/$TIMESTAMP /var/www/choremanager/current" From c2adaf3e06e78749623f6994f078f30ddc759b0a Mon Sep 17 00:00:00 2001 From: Jordan Welch Date: Sun, 13 Oct 2024 20:29:52 -0500 Subject: [PATCH 2/4] WIP --- .github/workflows/deploy-gcp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-gcp.yml b/.github/workflows/deploy-gcp.yml index 9b91cc9..d3b775d 100644 --- a/.github/workflows/deploy-gcp.yml +++ b/.github/workflows/deploy-gcp.yml @@ -32,8 +32,8 @@ jobs: - name: Install Node.js uses: actions/setup-node@v4 with: - node-version: '18.13.0' - cache: 'yarn' + node-version-file: .nvmrc + cache: 'npm' - name: Install npm dependencies run: yarn install From caefab7bec509906e054f05caf2d1c58d8dbe2ad Mon Sep 17 00:00:00 2001 From: Jordan Welch Date: Sun, 13 Oct 2024 20:32:41 -0500 Subject: [PATCH 3/4] WIP --- .github/workflows/deploy-gcp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-gcp.yml b/.github/workflows/deploy-gcp.yml index d3b775d..effb409 100644 --- a/.github/workflows/deploy-gcp.yml +++ b/.github/workflows/deploy-gcp.yml @@ -36,10 +36,10 @@ jobs: cache: 'npm' - name: Install npm dependencies - run: yarn install + run: npm ci - name: Build assets - run: yarn run build + run: npm run build - name: Zip up the application run: zip -r application.zip . -x "*.git*" -x "*.github*" From c8fc8e8d6ccda96282ca8b6caedccefec60098d2 Mon Sep 17 00:00:00 2001 From: Jordan Welch Date: Sun, 13 Oct 2024 20:35:42 -0500 Subject: [PATCH 4/4] WIP --- .github/workflows/deploy-gcp.yml | 8 ++++---- .github/workflows/fix.yml | 6 +++--- .github/workflows/qc.yml | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy-gcp.yml b/.github/workflows/deploy-gcp.yml index effb409..c8b47f5 100644 --- a/.github/workflows/deploy-gcp.yml +++ b/.github/workflows/deploy-gcp.yml @@ -51,12 +51,12 @@ jobs: path: application.zip - name: Place SSH Key - run: echo "${{ secrets.SERVER_SSH_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa + run: echo "${{ secrets.SERVER_SSH_KEY }}" > ./id_rsa && chmod 600 ./id_rsa - name: Transfer Zip to Server run: | TIMESTAMP=$(date +'%Y%m%d%H%M%S') SERVER="${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}" - scp application.zip $SERVER:/tmp/application.zip - ssh $SERVER "unzip /tmp/application.zip -d /var/www/choremanager/releases/$TIMESTAMP" - ssh $SERVER "ln -sf /var/www/choremanager/releases/$TIMESTAMP /var/www/choremanager/current" + scp -i ./id_rsa application.zip $SERVER:/tmp/application.zip + ssh -i ./id_rsa $SERVER "unzip /tmp/application.zip -d /var/www/choremanager/releases/$TIMESTAMP" + ssh -i ./id_rsa $SERVER "ln -sf /var/www/choremanager/releases/$TIMESTAMP /var/www/choremanager/current" diff --git a/.github/workflows/fix.yml b/.github/workflows/fix.yml index c94cb0b..5ecc535 100644 --- a/.github/workflows/fix.yml +++ b/.github/workflows/fix.yml @@ -1,7 +1,7 @@ name: Fix Code Style -on: - pull_request: - types: [ opened, synchronize, reopened, ready_for_review ] +# on: +# pull_request: +# types: [ opened, synchronize, reopened, ready_for_review ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true diff --git a/.github/workflows/qc.yml b/.github/workflows/qc.yml index 7826d69..d6a7597 100644 --- a/.github/workflows/qc.yml +++ b/.github/workflows/qc.yml @@ -1,11 +1,11 @@ name: QC run-name: 'QC (PR #${{ github.event.pull_request.number }})' -on: - pull_request: - types: [opened, synchronize, reopened] - workflow_call: - workflow_dispatch: +# on: +# pull_request: +# types: [opened, synchronize, reopened] +# workflow_call: +# workflow_dispatch: concurrency: group: qc-${{ github.event.pull_request.number }}