-
-
Notifications
You must be signed in to change notification settings - Fork 2
136 lines (109 loc) · 3.91 KB
/
test-php.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
130
131
132
133
134
135
136
name: Test PHP
on:
push:
branches:
- main
pull_request:
branches:
- main
- 'feature/**'
jobs:
test-php:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Setup SSH private key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
- name: Configure Git
run: |
git config --global user.name "${{ secrets.DEPLOY_USER_NAME }}"
git config --global user.email "${{ secrets.DEPLOY_USER_EMAIL }}"
- name: Install dependencies
run: composer install
- name: Check coding standards
run: composer lint
- name: Run tests
run: XDEBUG_MODE=coverage composer test
- name: Upload coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: ${{github.job}}-code-coverage-report-${{ matrix.php-versions }}
path: ./.coverage-html
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4
with:
files: ./cobertura.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
needs: test-php
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Setup SSH private key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
- name: Configure Git
run: |
git config --global user.name "${{ secrets.DEPLOY_USER_NAME }}"
git config --global user.email "${{ secrets.DEPLOY_USER_EMAIL }}"
- name: Install dependencies
run: composer install
- name: Demonstration of deployment in 'force-push' mode.
run: |
TEST_FILE="test-file-force-push-github-$(date "+%Y%m%d-%H%M%S").txt"
touch $TEST_FILE
vendor/bin/robo artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode-force-push-github \
--mode=force-push \
--report=$HOME/report-mode-force-push.txt \
--push
DEPLOY_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report-mode-force-push.txt | sed 's/ //g')
echo "Deployed to $DEPLOY_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOY_BRANCH/$TEST_FILE"
- name: Demonstration of deployment in 'branch' mode.
run: |
TEST_FILE="test-file-branch-github-$(date "+%Y%m%d-%H%M%S").txt"
touch $TEST_FILE
vendor/bin/robo artifact \
[email protected]:drevops/git-artifact-destination.git \
--branch=mode-branch-github-[timestamp:Y-m-d_H-i-s] \
--mode=branch \
--report=$HOME/report-mode-branch.txt \
--push
DEPLOY_BRANCH=$(sed -n 's/Remote branch://p' $HOME/report-mode-branch.txt | sed 's/ //g')
echo "Deployed to $DEPLOY_BRANCH"
echo
echo "See https://github.com/drevops/git-artifact-destination/blob/$DEPLOY_BRANCH/$TEST_FILE"