-
Notifications
You must be signed in to change notification settings - Fork 9
84 lines (65 loc) · 2.38 KB
/
test-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
name: Test and deploy
on: push
jobs:
deploy:
name: Lint, Test and Deploy
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer:v2
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache Composer packages
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Log in to the Docker container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull custom Docker images
run: docker compose pull wordpress mkcert
- name: Install Node dependencies
run: npm install --ignore-scripts
- name: Install Composer dependencies
run: composer install
- name: Lint
run: npm run lint
- name: Setup tests
run: mkdir uploads
- name: Test
run: npm run test
- name: Setup SSH deploy key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DEPLOY_SSH_KEY }}
known_hosts: github.com
- name: Setup Git credentials
run: |
git config --global user.name "XWP Deploy Bot"
git config --global user.email "[email protected]"
- name: Deploy to develop
if: github.ref_name == 'develop'
run: npm run deploy-staging
- name: Deploy to production
if: github.ref_name == 'master'
run: npm run deploy-production
- name: Set NewRelic deploy marker
env:
NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }}
if: ${{ env.NEW_RELIC_API_KEY != null && github.ref_name == 'master' }}
run: npm run newrelic-mark-deploy -- --search "*-production" --api_key "${{ secrets.NEW_RELIC_API_KEY }}" --commit "${{ github.sha }}" --user "${{ github.actor }}" --description "$(git log -1 --pretty=%B)"