|
| 1 | +name: Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + # JOB to detect changes in subfolders |
| 10 | + changes: |
| 11 | + name: Check for changes |
| 12 | + runs-on: ubuntu-latest |
| 13 | + # Set job outputs to values from filter step |
| 14 | + outputs: |
| 15 | + demo-blog: ${{ steps.filter.outputs.demo-blog }} |
| 16 | + demo-cooking: ${{ steps.filter.outputs.demo-cooking }} |
| 17 | + demo-starter: ${{ steps.filter.outputs.demo-starter }} |
| 18 | + shared: ${{ steps.filter.outputs.shared }} |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v3 |
| 21 | + - uses: dorny/paths-filter@v2 |
| 22 | + id: filter |
| 23 | + with: |
| 24 | + # Use context to get the branch where commits were pushed. |
| 25 | + base: ${{ github.ref }} |
| 26 | + filters: | |
| 27 | + demo-blog: |
| 28 | + - '.blog/**' |
| 29 | + - '.github/env/demo-blog/**' |
| 30 | + demo-cooking: |
| 31 | + - '.cooking/**' |
| 32 | + - '.github/env/demo-cooking/**' |
| 33 | + demo-starter: |
| 34 | + - '.starter/**' |
| 35 | + - '.github/env/demo-starter/**' |
| 36 | + shared: |
| 37 | + - 'components/**' |
| 38 | + - 'composables/**' |
| 39 | + - 'layouts/**' |
| 40 | + - 'server/**' |
| 41 | + - 'styles/**' |
| 42 | + - 'types/**' |
| 43 | + - 'utils/**' |
| 44 | + - '.npmrc' |
| 45 | + - 'app.config.ts' |
| 46 | + - 'app.vue' |
| 47 | + - 'nuxt.config.ts' |
| 48 | + - 'nuxt.schema.ts' |
| 49 | + - 'package.json' |
| 50 | + - 'pnpm-lock.yaml' |
| 51 | + - 'tailwind.config.cjs' |
| 52 | + - 'tokens.config.ts' |
| 53 | + - 'tsconfig.json' |
| 54 | + - '.github/env/shared/**' |
| 55 | + - '.github/workflow/deploy.yml' |
| 56 | +
|
| 57 | + build-blog: |
| 58 | + name: Build Stylô blog |
| 59 | + needs: changes |
| 60 | + if: ${{ needs.changes.outputs.shared == 'true' || needs.changes.outputs.demo-blog == 'true' }} |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v3 |
| 64 | + |
| 65 | + - run: corepack enable |
| 66 | + - run: pnpm install |
| 67 | + - run: pnpm build |
| 68 | + - run: cp .github/env/shared/Dockerfile .blog/Dockerfile |
| 69 | + |
| 70 | + - name: Set up dockertags |
| 71 | + run: | |
| 72 | + echo "dockertags=digisquad/cssninja.stylo.demo-blog:latest" >> $GITHUB_ENV |
| 73 | +
|
| 74 | + - name: Set up QEMU |
| 75 | + uses: docker/setup-qemu-action@v2 |
| 76 | + |
| 77 | + - name: Set up Docker Buildx |
| 78 | + uses: docker/setup-buildx-action@v2 |
| 79 | + |
| 80 | + - name: Login to DockerHub |
| 81 | + uses: docker/login-action@v2 |
| 82 | + with: |
| 83 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 84 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 85 | + |
| 86 | + - name: Build and push |
| 87 | + uses: docker/build-push-action@v3 |
| 88 | + timeout-minutes: 60 |
| 89 | + with: |
| 90 | + push: true |
| 91 | + context: .blog |
| 92 | + tags: ${{ env.dockertags }} |
| 93 | + |
| 94 | + deploy-blog: |
| 95 | + name: Deploy Stylô blog |
| 96 | + needs: build-blog |
| 97 | + runs-on: ubuntu-latest |
| 98 | + |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v3 |
| 101 | + - name: Prepare |
| 102 | + uses: appleboy/ssh-action@master |
| 103 | + with: |
| 104 | + host: ${{ secrets.SSH_HOST }} |
| 105 | + username: ${{ secrets.SSH_USER }} |
| 106 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 107 | + script_stop: true |
| 108 | + script: mkdir -p ${{ secrets.BLOG_HOST_DIRECTORY }} |
| 109 | + |
| 110 | + - name: Publish |
| 111 | + uses: appleboy/scp-action@master |
| 112 | + with: |
| 113 | + host: ${{ secrets.SSH_HOST }} |
| 114 | + username: ${{ secrets.SSH_USER }} |
| 115 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 116 | + source: .github/env/demo-blog/docker-compose.yml |
| 117 | + target: ${{ secrets.BLOG_HOST_DIRECTORY }} |
| 118 | + strip_components: 3 |
| 119 | + |
| 120 | + - name: Deploy |
| 121 | + uses: appleboy/ssh-action@master |
| 122 | + with: |
| 123 | + host: ${{ secrets.SSH_HOST }} |
| 124 | + username: ${{ secrets.SSH_USER }} |
| 125 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 126 | + script_stop: true |
| 127 | + script: | |
| 128 | + cd ${{ secrets.BLOG_HOST_DIRECTORY }} |
| 129 | + docker compose pull |
| 130 | + docker compose up -d --force-recreate --remove-orphans |
| 131 | +
|
| 132 | + build-cooking: |
| 133 | + name: Build Stylô cooking |
| 134 | + needs: changes |
| 135 | + if: ${{ needs.changes.outputs.shared == 'true' || needs.changes.outputs.demo-cooking == 'true' }} |
| 136 | + runs-on: ubuntu-latest |
| 137 | + steps: |
| 138 | + - uses: actions/checkout@v3 |
| 139 | + |
| 140 | + - run: corepack enable |
| 141 | + - run: pnpm install |
| 142 | + - run: pnpm build |
| 143 | + - run: cp .github/env/shared/Dockerfile .cooking/Dockerfile |
| 144 | + |
| 145 | + - name: Set up dockertags |
| 146 | + run: | |
| 147 | + echo "dockertags=digisquad/cssninja.stylo.demo-cooking:latest" >> $GITHUB_ENV |
| 148 | +
|
| 149 | + - name: Set up QEMU |
| 150 | + uses: docker/setup-qemu-action@v2 |
| 151 | + |
| 152 | + - name: Set up Docker Buildx |
| 153 | + uses: docker/setup-buildx-action@v2 |
| 154 | + |
| 155 | + - name: Login to DockerHub |
| 156 | + uses: docker/login-action@v2 |
| 157 | + with: |
| 158 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 159 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 160 | + |
| 161 | + - name: Build and push |
| 162 | + uses: docker/build-push-action@v3 |
| 163 | + timeout-minutes: 60 |
| 164 | + with: |
| 165 | + push: true |
| 166 | + context: .cooking |
| 167 | + tags: ${{ env.dockertags }} |
| 168 | + |
| 169 | + deploy-cooking: |
| 170 | + name: Deploy Stylô cooking |
| 171 | + needs: build-cooking |
| 172 | + runs-on: ubuntu-latest |
| 173 | + |
| 174 | + steps: |
| 175 | + - uses: actions/checkout@v3 |
| 176 | + - name: Prepare |
| 177 | + uses: appleboy/ssh-action@master |
| 178 | + with: |
| 179 | + host: ${{ secrets.SSH_HOST }} |
| 180 | + username: ${{ secrets.SSH_USER }} |
| 181 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 182 | + script_stop: true |
| 183 | + script: mkdir -p ${{ secrets.COOKING_HOST_DIRECTORY }} |
| 184 | + |
| 185 | + - name: Publish |
| 186 | + uses: appleboy/scp-action@master |
| 187 | + with: |
| 188 | + host: ${{ secrets.SSH_HOST }} |
| 189 | + username: ${{ secrets.SSH_USER }} |
| 190 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 191 | + source: .github/env/demo-cooking/docker-compose.yml |
| 192 | + target: ${{ secrets.COOKING_HOST_DIRECTORY }} |
| 193 | + strip_components: 3 |
| 194 | + |
| 195 | + - name: Deploy |
| 196 | + uses: appleboy/ssh-action@master |
| 197 | + with: |
| 198 | + host: ${{ secrets.SSH_HOST }} |
| 199 | + username: ${{ secrets.SSH_USER }} |
| 200 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 201 | + script_stop: true |
| 202 | + script: | |
| 203 | + cd ${{ secrets.COOKING_HOST_DIRECTORY }} |
| 204 | + docker compose pull |
| 205 | + docker compose up -d --force-recreate --remove-orphans |
| 206 | +
|
| 207 | + build-starter: |
| 208 | + name: Build Stylô starter |
| 209 | + needs: changes |
| 210 | + if: ${{ needs.changes.outputs.shared == 'true' || needs.changes.outputs.demo-starter == 'true' }} |
| 211 | + runs-on: ubuntu-latest |
| 212 | + steps: |
| 213 | + - uses: actions/checkout@v3 |
| 214 | + |
| 215 | + - run: corepack enable |
| 216 | + - run: pnpm install |
| 217 | + - run: pnpm build |
| 218 | + - run: cp .github/env/shared/Dockerfile .starter/Dockerfile |
| 219 | + |
| 220 | + - name: Set up dockertags |
| 221 | + run: | |
| 222 | + echo "dockertags=digisquad/cssninja.stylo.demo-starter:latest" >> $GITHUB_ENV |
| 223 | +
|
| 224 | + - name: Set up QEMU |
| 225 | + uses: docker/setup-qemu-action@v2 |
| 226 | + |
| 227 | + - name: Set up Docker Buildx |
| 228 | + uses: docker/setup-buildx-action@v2 |
| 229 | + |
| 230 | + - name: Login to DockerHub |
| 231 | + uses: docker/login-action@v2 |
| 232 | + with: |
| 233 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 234 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 235 | + |
| 236 | + - name: Build and push |
| 237 | + uses: docker/build-push-action@v3 |
| 238 | + timeout-minutes: 60 |
| 239 | + with: |
| 240 | + push: true |
| 241 | + context: .starter |
| 242 | + tags: ${{ env.dockertags }} |
| 243 | + |
| 244 | + deploy-starter: |
| 245 | + name: Deploy Stylô starter |
| 246 | + needs: build-starter |
| 247 | + runs-on: ubuntu-latest |
| 248 | + |
| 249 | + steps: |
| 250 | + - uses: actions/checkout@v3 |
| 251 | + - name: Prepare |
| 252 | + uses: appleboy/ssh-action@master |
| 253 | + with: |
| 254 | + host: ${{ secrets.SSH_HOST }} |
| 255 | + username: ${{ secrets.SSH_USER }} |
| 256 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 257 | + script_stop: true |
| 258 | + script: mkdir -p ${{ secrets.STARTER_HOST_DIRECTORY }} |
| 259 | + |
| 260 | + - name: Publish |
| 261 | + uses: appleboy/scp-action@master |
| 262 | + with: |
| 263 | + host: ${{ secrets.SSH_HOST }} |
| 264 | + username: ${{ secrets.SSH_USER }} |
| 265 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 266 | + source: .github/env/demo-starter/docker-compose.yml |
| 267 | + target: ${{ secrets.STARTER_HOST_DIRECTORY }} |
| 268 | + strip_components: 3 |
| 269 | + |
| 270 | + - name: Deploy |
| 271 | + uses: appleboy/ssh-action@master |
| 272 | + with: |
| 273 | + host: ${{ secrets.SSH_HOST }} |
| 274 | + username: ${{ secrets.SSH_USER }} |
| 275 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 276 | + script_stop: true |
| 277 | + script: | |
| 278 | + cd ${{ secrets.STARTER_HOST_DIRECTORY }} |
| 279 | + docker compose pull |
| 280 | + docker compose up -d --force-recreate --remove-orphans |
| 281 | +
|
| 282 | +
|
0 commit comments