-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (66 loc) · 3.4 KB
/
upload-db-assets.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
name: Publish Release db dump assets
on:
workflow_call:
inputs:
db-type:
description: "Database type"
required: true
type: string
db-version:
description: "Database version"
required: true
type: string
permissions:
contents: write
env:
DB_CONNECTION: ${{ inputs.db-type }}
DB_PORT: ${{ inputs.db-type == 'mysql' && '3306' || inputs.db-type == 'pgsql' && '5432' }}
DB_USERNAME: radioroster
DB_PASSWORD: releasePassword
DB_DATABASE: radioroster
APP_ENV: production
APP_DEBUG: false
jobs:
mariadb-release-dump:
name: Add ${{ inputs.db-type == 'mysql' && 'MariaDB' || inputs.db-type == 'pgsql' && 'PostgreSQL' }} ${{ inputs.db-version }} dump to release
runs-on: ubuntu-latest
steps:
- if: ${{ inputs.db-type == 'mysql' }}
name: Setup MariaDB ${{ inputs.db-version }}
run: |
docker run -d --name mariadb -e MARIADB_RANDOM_ROOT_PASSWORD=true -e MARIADB_DATABASE=${{ env.DB_DATABASE }} -e MARIADB_USER=${{ env.DB_USERNAME }} -e MARIADB_PASSWORD=${{ env.DB_PASSWORD }} --publish 3306:3306 mariadb:${{ inputs.db-version }}
- if: ${{ inputs.db-type == 'pgsql' }}
name: Setup PostgreSQL ${{ inputs.db-version }}
run: |
docker run -d --name postgres -e POSTGRES_DB=${{ env.DB_DATABASE }} -e POSTGRES_USER=${{ env.DB_USERNAME }} -e POSTGRES_PASSWORD=${{ env.DB_PASSWORD }} --publish 5432:5432 postgres:${{ inputs.db-version }}
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Setup PHP 8.1
uses: shivammathur/setup-php@67271131b1870a5a241694badbda0ac2cae0648e
with:
php-version: "8.1"
extensions: pcntl, zip, intl, exif, mbstring, dom, fileinfo, ${{ inputs.db-type == 'mysql' && 'pdo_mysql' || inputs.db-type == 'pgsql' && 'pdo_pgsql' }}
- name: Install Composer Dependencies
run: composer install -q --no-interaction --no-scripts --no-progress --prefer-dist --optimize-autoloader
- name: Prepare Laravel Application
run: |
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear config
run: php artisan config:clear
- name: Run Migrations
run: php artisan migrate --force
- if: ${{ inputs.db-type == 'mysql' }}
name: Dump MariaDB ${{ inputs.db-type == 'mysql' && inputs.db-version }} database
run: |
mkdir -p database/dumps
docker exec mariadb mysqldump --user $DB_USERNAME --password=$DB_PASSWORD $DB_DATABASE | gzip > database/dumps/radioroster_${{ github.ref_name }}-mariadb${{ inputs.db-version }}.sql.gz
- if: ${{ inputs.db-type == 'pgsql' }}
name: Dump PostgreSQL ${{ inputs.db-type == 'pgsql' && inputs.db-version }} database
run: |
mkdir -p database/dumps
docker exec postgres sh -c 'export PGPASSWORD=${{ env.DB_PASSWORD }} && pg_dump -Fc -Z 6 -U${{ env.DB_USERNAME }} $DB_DATABASE' > database/dumps/radioroster_${{ github.ref_name }}-postgres${{ inputs.db-version }}.sql.gz
- name: Upload database dump
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
with:
files: database/dumps/radioroster_${{ github.ref_name }}${{ inputs.db-type == 'mysql' && '-mariadb' || inputs.db-type == 'pgsql' && '-postgres' }}${{ inputs.db-version }}.sql.gz