-
-
Notifications
You must be signed in to change notification settings - Fork 3
129 lines (113 loc) · 4.02 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Deploy
run-name: >-
deploy ${{ github.ref_name }} to ${{ github.event_name == 'workflow_dispatch' && inputs.target || 'staging' }}
on:
release:
types: [published]
workflow_dispatch:
inputs:
target:
description: Deployment target
required: true
type: environment
reset:
description: Reset database
default: false
type: boolean
workflow_run:
workflows: [Code Quality]
types: [completed]
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: Prepare
uses: projek-xyz/actions/.github/workflows/configure.yml@main
if: ${{ github.event.workflow_run.conclusion == 'success' }}
with:
php-version: 8.2
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
build:
name: Build
needs: prepare
uses: projek-xyz/actions/.github/workflows/build.yml@main
secrets:
ACCESS_TOKEN: ${{ secrets.PAT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
with:
branch: ${{ needs.prepare.outputs.target-branch }}
composer-cache: ${{ needs.prepare.outputs.composer-cache }}
composer-cache-key: ${{ needs.prepare.outputs.composer-cache-key }}
sentry-project: ${{ vars.SENTRY_PROJECT }}
target-env: ${{ github.event_name == 'workflow_dispatch' && inputs.target || matrix.target }}
target-url: ${{ vars.APP_URL }}
strategy:
matrix:
target: [staging]
deploy:
runs-on: ubuntu-latest
name: Deploy to ${{ needs.build.outputs.target-env }}
if: ${{ success() }}
needs: build
environment:
name: ${{ needs.build.outputs.target-env }}
url: ${{ needs.build.outputs.target-url }}
env:
APP_ENV: ${{ needs.build.outputs.target-env }}
APP_URL: ${{ needs.build.outputs.target-url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
extensions: curl, pcntl, ssh2, zip
tools: composer:v2
coverage: none
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Download assets
id: download
uses: actions/download-artifact@v4
with:
name: build-${{ env.APP_ENV }}
path: public
- name: Prepare environment
env:
SSH_RSAKEY: ${{ secrets.DEPLOY_SSH_RSAKEY }}
SSH_CONFIG: ${{ secrets.DEPLOY_SSH_CONFIG }}
run: |
[[ ! -d $HOME/.ssh ]] && mkdir $HOME/.ssh
echo "$SSH_RSAKEY" >> $HOME/.ssh/id_rsa
echo "$SSH_CONFIG" >> $HOME/.ssh/config
chmod 600 $HOME/.ssh/*
- name: Deploy
run: |
git config --global user.name "Creasi.HQ" && git config --global user.email "[email protected]"
git clone creasi.co:~/git/creasico-skeleton.git storage/deploy-tmp
./scripts/deploy.sh ${{ env.APP_ENV }}
# - name: Cache Composer dependencies
# uses: actions/cache@v4
# with:
# path: ${{ needs.prepare.outputs.composer-cache }}
# key: php-8.2-composer-${{ hashFiles('**/composer.lock') }}
# restore-keys: php-8.2-composer-
# - name: Install dependencies
# run: composer install --prefer-dist --no-interaction --no-progress --ansi
# - name: Deploy
# uses: deployphp/action@master
# env:
# DB_USERNAME: ${{ secrets.DB_USERNAME }}
# DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
# DB_RESET: ${{ github.event_name == 'workflow_dispatch' && inputs.reset || false }}
# DEPLOY_ARGS: --branch ${{ needs.prepare.outputs.target-branch }} --${{ env.DB_RESET == 'true' && 'reset' || 'no-reset' }}
# with:
# private-key: ${{ secrets.DEPLOY_SSH_RSAKEY }}
# ssh-config: ${{ secrets.DEPLOY_SSH_CONFIG }}
# verbosity: ''
# dep: deploy -f scripts/deploy.php env=staging ${{ env.DEPLOY_ARGS }}