-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (56 loc) · 2.1 KB
/
sync-db.yml
File metadata and controls
68 lines (56 loc) · 2.1 KB
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
name: "Manage: Sync Production"
on:
workflow_call:
secrets:
DEPLOY_SSH_PRIVATE_KEY:
required: true
NPM_FONTAWESOME_AUTH_TOKEN:
required: true
PACKAGIST_GITHUB_TOKEN:
required: true
DB_ARTIFACT_KEY:
required: true
permissions:
contents: read
jobs:
sync:
name: Pull, sanitize and upload DB
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: generoi/github-actions/ssh-agent@v1
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
- name: Setup project
uses: generoi/github-actions/setup@v1
with:
npm_fontawesome_auth_token: ${{ secrets.NPM_FONTAWESOME_AUTH_TOKEN }}
packagist_github_token: ${{ secrets.PACKAGIST_GITHUB_TOKEN }}
- name: Install dependencies
run: composer install:development
- name: Add remote public keys to known hosts
run: ssh-keyscan -p $(./vendor/bin/robo config env.@production.port || echo 22) $(./vendor/bin/robo config env.@production.host) >> ~/.ssh/known_hosts
- name: Setup DDEV
uses: generoi/github-actions/setup-ddev@v1
- name: Pull database from production
run: ./vendor/bin/robo db:pull @production
- name: Sanitize and export
run: |
mkdir -p .github/fixtures
ddev exec CI=true wp db export-clean .github/fixtures/sanitized-db.sql --remove-keys
gzip -f .github/fixtures/sanitized-db.sql
- name: Encrypt artifact
env:
DB_ARTIFACT_KEY: ${{ secrets.DB_ARTIFACT_KEY }}
run: |
openssl enc -aes-256-cbc -pbkdf2 -salt \
-in .github/fixtures/sanitized-db.sql.gz \
-out .github/fixtures/sanitized-db.sql.gz.enc \
-pass env:DB_ARTIFACT_KEY
- name: Upload sanitized DB artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: sanitized-db
path: .github/fixtures/sanitized-db.sql.gz.enc
retention-days: 90