|
10 | 10 |
|
11 | 11 | jobs:
|
12 | 12 | build:
|
13 |
| - name: Build PHP |
| 13 | + name: Build |
14 | 14 | runs-on: ubuntu-latest
|
15 | 15 | steps:
|
16 | 16 |
|
|
59 | 59 |
|
60 | 60 | - name: Yarn build
|
61 | 61 | run: yarn build
|
| 62 | + |
| 63 | + deployment: |
| 64 | + name: Deployment |
| 65 | + runs-on: ubuntu-latest |
| 66 | + environment: |
| 67 | + name: production |
| 68 | + url: https://sitepackagebuilder.com |
| 69 | + needs: [build] |
| 70 | + if: (github.ref == 'refs/heads/master') && github.event_name != 'pull_request' && (github.repository == 'benjaminkott/packagebuilder') |
| 71 | + steps: |
| 72 | + |
| 73 | + - name: Checkout Code |
| 74 | + uses: actions/checkout@v2 |
| 75 | + |
| 76 | + - name: Set up PHP 7.4 |
| 77 | + uses: shivammathur/setup-php@v2 |
| 78 | + with: |
| 79 | + php-version: 7.4 |
| 80 | + tools: composer:v2 |
| 81 | + |
| 82 | + - name: Download Deployer |
| 83 | + run: | |
| 84 | + curl -LO https://github.com/deployphp/deployer/releases/download/v7.0.0-beta.37/deployer.phar |
| 85 | + sudo mv deployer.phar /usr/local/bin/dep; |
| 86 | + sudo chmod +x /usr/local/bin/dep; |
| 87 | + dep self-update; |
| 88 | +
|
| 89 | + - name: Get Composer cache directory path |
| 90 | + id: composer-cache |
| 91 | + run: | |
| 92 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 93 | +
|
| 94 | + - uses: actions/cache@v2 |
| 95 | + with: |
| 96 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 97 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 98 | + restore-keys: | |
| 99 | + ${{ runner.os }}-composer- |
| 100 | +
|
| 101 | + - name: Set ENV |
| 102 | + run: "echo \"APP_ENV=prod\" >> .env.local" |
| 103 | + |
| 104 | + - name: Build PHP |
| 105 | + run: composer install --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader |
| 106 | + |
| 107 | + - name: Get yarn cache directory path |
| 108 | + id: yarn-cache-dir-path |
| 109 | + run: echo "::set-output name=dir::$(yarn cache dir)" |
| 110 | + |
| 111 | + - uses: actions/cache@v2 |
| 112 | + id: yarn-cache |
| 113 | + with: |
| 114 | + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
| 115 | + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
| 116 | + restore-keys: | |
| 117 | + ${{ runner.os }}-yarn- |
| 118 | +
|
| 119 | + - name: Build Frontend |
| 120 | + run: yarn install --silent && yarn build |
| 121 | + |
| 122 | + - name: Setup SSH Key |
| 123 | + env: |
| 124 | + SSH_AUTH_SOCK: /tmp/ssh-auth.sock |
| 125 | + run: | |
| 126 | + mkdir -p ~/.ssh |
| 127 | + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_rsa |
| 128 | + chmod 0600 ~/.ssh/deploy_rsa |
| 129 | + ssh-keygen -p -P "${{ secrets.SSH_PASSPHRASE }}" -N "" -f ~/.ssh/deploy_rsa |
| 130 | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null |
| 131 | + ssh-add ~/.ssh/deploy_rsa |
| 132 | + ssh-keyscan ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts |
| 133 | +
|
| 134 | + - name: Deploy |
| 135 | + env: |
| 136 | + SSH_HOST: ${{ secrets.SSH_HOST }} |
| 137 | + SSH_USER: ${{ secrets.SSH_USER }} |
| 138 | + SSH_AUTH_SOCK: /tmp/ssh-auth.sock |
| 139 | + run: | |
| 140 | + dep deploy; |
0 commit comments