add github action for edxapp db dump
This commit is contained in:
24
.github/workflows/docker-compose.yml.mysqldbdump
vendored
Normal file
24
.github/workflows/docker-compose.yml.mysqldbdump
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
version: '3'
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.6
|
||||
container_name: edx.devstack.mysql
|
||||
ports:
|
||||
- '3306:3306'
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ""
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
||||
volumes:
|
||||
- ./init:/docker-entrypoint-initdb.d
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||
timeout: 20s
|
||||
retries: 10
|
||||
edxapp:
|
||||
image: edxops/edxapp:latest
|
||||
command: bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && /edx/app/edxapp/venvs/edxapp/bin/python manage.py lms migrate && /edx/app/edxapp/venvs/edxapp/bin/python manage.py cms migrate'
|
||||
volumes:
|
||||
- ../../:/edx/app/edxapp/edx-platform
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
3
.github/workflows/init/01.sql
vendored
Normal file
3
.github/workflows/init/01.sql
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE DATABASE IF NOT EXISTS `edxapp`;
|
||||
CREATE DATABASE IF NOT EXISTS `edxapp_csmh`;
|
||||
GRANT ALL PRIVILEGES ON *.* TO 'edxapp001'@'%' IDENTIFIED BY 'password';
|
||||
20
.github/workflows/mysqldbdump.yml
vendored
Normal file
20
.github/workflows/mysqldbdump.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: mysqldbdump
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
jobs:
|
||||
mysqldbdump:
|
||||
name: mysqldbdump
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
- name: Migrate
|
||||
run: docker-compose -f ./.github/workflows/docker-compose.yml.mysqldbdump up -d
|
||||
- name: Dump database
|
||||
run: docker exec -i edx.devstack.mysql mysqldump -u'edxapp001' -p'password' edxapp > edxapp.sql
|
||||
- name: Commit dump file to repo.
|
||||
run: ./.github/workflows/mysqldbdump_pr.sh
|
||||
env:
|
||||
GH_ACCESS_TOKEN: ${{ secrets.EDX_DEPLOYMENT_GH_TOKEN }}
|
||||
29
.github/workflows/mysqldbdump_pr.sh
vendored
Executable file
29
.github/workflows/mysqldbdump_pr.sh
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
export GITHUB_USER='edx-deployment'
|
||||
export GITHUB_TOKEN=$GH_ACCESS_TOKEN
|
||||
export GITHUB_EMAIL='edx-deployment@edx.org'
|
||||
export REPO_NAME='edx-platform'
|
||||
export DB_NAME='edxapp'
|
||||
|
||||
cd ..
|
||||
|
||||
# install hub
|
||||
curl -L -o hub.tgz https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz
|
||||
tar -zxvf hub.tgz
|
||||
|
||||
cd "$REPO_NAME"
|
||||
|
||||
git config --global user.name "${GITHUB_USER}"
|
||||
git config --global user.email "${GITHUB_EMAIL}"
|
||||
|
||||
obsolete_dump_pr=`../hub-linux*/bin/hub pr list -s open | grep 'github-actions-mysqldbdump' | awk '{print $1}' | sed 's/\#//g'`
|
||||
if [[ ! -z $obsolete_dump_pr ]]; then
|
||||
../hub-linux*/bin/hub issue update $obsolete_dump_pr -s closed
|
||||
fi
|
||||
|
||||
git checkout -b github-actions-mysqldbdump/$GITHUB_SHA
|
||||
git add "${DB_NAME}".sql
|
||||
git commit -m "MySQLdbdump" --author "GitHub Actions MySQLdbdump automation <admin@edx.org>"
|
||||
git push --set-upstream origin github-actions-mysqldbdump/$GITHUB_SHA
|
||||
../hub-linux*/bin/hub pull-request -m "${DB_NAME} MySQL database dump" -m "MySQL database dump" -l github-actions-mysqldbdump
|
||||
Reference in New Issue
Block a user